codeigniter

How to route URIs to application/controllers & still use Module::run in CI3 with HMVC

◇◆丶佛笑我妖孽 提交于 2019-12-24 05:48:38
问题 I only use the modules for partial views, they are never routed to directly. Instead I have main controllers inside application/controllers and views inside application/views/ which execute Modules::run($moduleName, $params); This invokes the module and renders fine, when reached. The problem is none of my routes are calling their application/controller/ methods . Meaning my routing has stopped working entirely and only the homepage defined by my route['default_controller'] works. Because my

How to load hook for particular controller

半世苍凉 提交于 2019-12-24 05:27:48
问题 I am new in codeigniter. I want to load hooks for admin panel controller. $hook['post_controller_constructor'][] = array( 'class' => 'AdminData', 'function' => 'myfunction', 'filename' => 'loginhelp.php', 'filepath' => 'hooks', 'params' => array() ); 回答1: The post_controller_constructor hook gets called after a $class is loaded. The class that gets loaded is based on the route parameters. system/core/Codeigniter.php /** *<code> * http://example.com/adminData/method *</code> * * $CI = new

Safe authentication in codeigniter

感情迁移 提交于 2019-12-24 05:21:20
问题 I'm trying to roll my own authentication system in codeigniter, and have stumbled onto a couple of roadblocks. If I have the sessions set to use a database, is userdata stored in the database alone or in the cookie as well? I'd like to store the hashed password in it to verify each page load that a user is actually logged in with the correct pass, and I do not want the hash to be accessible clientside at all. How can I prevent sessions from being stolen? I've enabled IP and hostname

Unable to insert array into database

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 05:14:28
问题 I am inserting multiple data from multiple forms into database but encounter an error at column photo Unknown column 'Array' in 'field list' Controller if(!empty($_FILES['user_profile_file']['name'])){ $filesCount = count($_FILES['user_profile_file']['name']); for ($i = 0; $i < $filesCount; $i++) { $studentImg = ''; $_FILES['userFile']['name'] = $_FILES['user_profile_file']['name'][$i]; $_FILES['userFile']['type'] = $_FILES['user_profile_file']['type'][$i]; $_FILES['userFile']['tmp_name'] = $

Codeigniter and SQL/Haversine Formula

ぃ、小莉子 提交于 2019-12-24 05:01:49
问题 I am using Codeigniter for a project and have some locations with latitude and longitude inputs on the database. I'm trying to get points within a certain distance (50km), and attempting it with the Haversine Formula. However, on my controller and view it doesn't print out the results. What I need to know is if there's any adjustments I need to make to get the model function working. Note: The DB table has the column names location_latitude and location_longitude. //base function to compare

Search with full name instead of just first name or last name

依然范特西╮ 提交于 2019-12-24 04:55:10
问题 I am developing an API built with PHP and Codeigniter and I use MySQL as database. I have a user table called Users which contains the following columns: - ID - Firstname - Lastname - Email How can a user search this table using a full name? For example it works fine to search either by Martin or Smith, but not Martin Smith. This is the query I am using now: $this->db->select('*'); $this->db->from('users'); $this->db->like('firstname', $args['query']); $this->db->or_like('lastname', $args[

PHP JSON header adding a line break before output

北城以北 提交于 2019-12-24 04:46:09
问题 I recently started having a problem where when I use the PHP header() command, it is adding a line-break after the command before the output is displayed. I am using CodeIgniter 2.2.2 and a slightly older version of the CodeIgniter Rest Controller from https://github.com/chriskacerguis/codeigniter-restserver. I was running on an Apache development environment with XAMPP using PHP 5.6.8. The issue seems to have started when I moved to Laravel Homestead for my environment which has PHP 5.6.7

MysqlError: Duplicate entry '1-5' for key 'PRIMARY' on insert unsure of how

左心房为你撑大大i 提交于 2019-12-24 04:37:28
问题 I am getting the error MysqlError: Duplicate entry '1-5' for key 'PRIMARY' as shown below in the code. It only happened once (that I could detect, but it was random) and I couldn't find a cause (New Relic reported), but I cannot reproduce and I don't have much more information except the line number and the error given. The schema and code is below. num_rows() is somehow returning a value that is not 1 even though it shouldn't. If someone can give some insight on how to debug or fix that

Array Manipulation of Codeigniter's Sessions

佐手、 提交于 2019-12-24 04:32:24
问题 Continue from this topic link text Hi guys. I am using codeigniter and want to store data in the session. I have this array array(4) { [0]=> array(2) { ["DESC"]=> string(1) "A" ["SUBFUNCTION_ID"]=> string(3) "904" } [1]=> array(2) { ["DESC"]=> string(1) "B" ["SUBFUNCTION_ID"]=> string(3) "903" } [2]=> array(2) { ["DESC"]=> string(1) "C" ["SUBFUNCTION_ID"]=> string(3) "902" } [3]=> array(2) { ["DESC"]=> string(1) "D" ["SUBFUNCTION_ID"]=> string(3) "901" } } And this is the array to store the

Codeigniter session hanging

岁酱吖の 提交于 2019-12-24 04:23:15
问题 So I'm using codeigniter for our internal intranet. Usually when doing database selections, updates, deletes etc, I use ajax, and use jquery to update the page without redirecting. I have a need to actually submit a form rather than relying on ajax. Once the database actions have been done, I set some session data using codeigniters sessions, then redirect the user back to the overview page, where it will retrieve information from the session and display it as a 'success' message. I can set