CodeIgniter call function within the same class

OK, I agree this is a MAJOR goof-up; comes from lack of OOP understanding; <?php class Inventory extends Controller { function current_stock() { //do something } function add_stock() { //do something-else $this->current_stock(); // and we called the other method here! } } Just that I didn”t expect it to be so easy

$this->session->set_flashdata() and then $this->session->flashdata() doesn’t work in codeigniter

Well, the documentation does actually state that CodeIgniter supports “flashdata”, or session data that will only be available for the next server request, and are then automatically cleared. as the very first thing, which obviusly means that you need to do a new server request. A redirect, a refresh, a link or some other mean … Read more

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 Disallowed Key Characters

The problem is you are using characters not included in the standard Regex. Use this: !preg_match(“/^[a-z0-9\x{4e00}-\x{9fa5}\:\;\.\,\?\!\@\#\$%\^\*\”\~\’+=\\\ &_\/\.\[\]-\}\{]+$/iu”, $str) As per the comments (and personal experience) you should not modify they Input.php file — rather, you should create/use your own MY_Input.php as follows: <?php class MY_Input extends CI_Input { /** * Clean Keys * * This … Read more

multiple where condition codeigniter

you can use an array and pass the array. Associative array method: $array = array(‘name’ => $name, ‘title’ => $title, ‘status’ => $status); $this->db->where($array); // Produces: WHERE name=”Joe” AND title=”boss” AND status=”active” Or if you want to do something other than = comparison $array = array(‘name !=’ => $name, ‘id <‘ => $id, ‘date >’ … Read more