codeigniter-2
CodeIgniter: INSERT multiple records without cycle
Codeigniter active record has a function insert_batch i think that is what you need $data = array( array( ‘title’ => ‘My title’ , ‘name’ => ‘My Name’ , ‘date’ => ‘My date’ ), array( ‘title’ => ‘Another title’ , ‘name’ => ‘Another Name’ , ‘date’ => ‘Another date’ ) ); $this->db->insert_batch(‘mytable’, $data); // Produces: INSERT … Read more
CodeIgniter PHP Model Access “Unable to locate the model you have specified”
When creating models, you need to place the file in application/models/ and name the file in all lowercase – like logon_model.php The logon_model.php should contain the following: <?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); class Logon_model extends CI_Model { public function __construct() { parent::__construct(); } … Now, what you can do, to … Read more
Codeigniter: does $this->db->last_query(); execute a query?
The query execution happens on all get methods like $this->db->get(‘table_name’); $this->db->get_where(‘table_name’,$array); While last_query contains the last query which was run $this->db->last_query(); If you want to get query string without execution you will have to do this. Go to system/database/DB_active_rec.php Remove public or protected keyword from these functions public function _compile_select($select_override = FALSE) public function _reset_select() … Read more
How do I run CodeIgniter migrations?
Using these pages as references: Running via the CLI and Migration Class you’re able to restrict access to your migration controller to command line with something along these lines (application/controllers/migrate.php): <?php if ( ! defined(‘BASEPATH’)) exit(“No direct script access allowed”); class Migrate extends CI_Controller { public function __construct() { parent::__construct(); $this->input->is_cli_request() or exit(“Execute via command … Read more
CodeIgniter: How to get Controller, Action, URL information
You could use the URI Class: $this->uri->segment(n); // n=1 for controller, n=2 for method, etc I’ve also been told that the following work, but am currently unable to test: $this->router->fetch_class(); $this->router->fetch_method();
Where do I put image files, css, js, etc. in Codeigniter?
I have a setup like this: application system assets js imgs css I then have a helper function that simply returns the full path to this depending on my setup, something similar to: application/helpers/utility_helper.php: function asset_url(){ return base_url().’assets/’; } I will usually keep common routines similar to this in the same file and autoload it … Read more
Only variable references should be returned by reference – Codeigniter
Edit filename: core/Common.php, line number: 257 Before return $_config[0] =& $config; After $_config[0] =& $config; return $_config[0]; Update Added by NikiC In PHP assignment expressions always return the assigned value. So $_config[0] =& $config returns $config – but not the variable itself, but a copy of its value. And returning a reference to a temporary … Read more