Category Archives: Codeigniter

CodeIgniter Autoload

To autoload resources, open the application/config/autoload.php file and add the item you want loaded to the autoload array. Important Points Of Autoload Concept Libraries Helper Config Language Model Sample autoload.php configuration Important Points Of Autoload Concept This file specifies which systems should be loaded by default (OR) The files initialized automatically every time the system […]

CodeIgniter Configuration

This config.php file are located under application/config filder or your own custom configuration file. This class is initialized automatically by the system so there is no need to do it manually. To load custom config file, we have to use the following function within the controller. $this->config->load(‘custom_config_file’); Where custom_config_file is the name of your config […]

CodeIgniter Database Configuration

Database Support Active Group Database Credentials database.php File Database Support The database.php file contains all the information to connect to a database. A Database is required for most web application programming. CodeIgniter supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, SQLite, and ODBC Active Group In codeigniter database configurtion, we could create number […]

CodeIgniter – Insert Query

CodeIgniter insert query will execute using following functions. They are $this->db->query() Insert With Query Bindings Standard Insert $this->db->insert_string() $this->db->insert_batch() Escaping Insert Queries Get Inserted ID Get Affected Rows $this->db->query() Program 1: $sql = “insert into tbl_user (name, age, groupname) values (‘codeigniter, 35, ‘Group 1’)”; $this->db->query($sql); Program 2: $data = array( ‘name’ = > $_POST[‘name’] , […]

CodeIgniter – Insert Query

CodeIgniter insert query will execute using following functions. They are $this->db->query() Insert With Query Bindings Standard Insert $this->db->insert_string() $this->db->insert_batch() Escaping Insert Queries Get Inserted ID Get Affected Rows $this->db->query() Program 1: $sql = “insert into tbl_user (name, age, groupname) values (‘codeigniter, 35, ‘Group 1’)”; $this->db->query($sql); Program 2: $data = array( ‘name’ = > $_POST[‘name’] , […]

CodeIgniter Installation Instructions

Download CodeIgniter CodeIgniter Installation Steps Normal Directory Structure Increase Security For Application Folder Download CodeIgniter Download the codeigniter latest version using the below urls Codeigniter Site Github CodeIgniter Installation Steps 1.Unzip the package. 2.Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root. 3.Open the application/config/config.php file […]

CodeIgniter – Join Query

CodeIgniter Join query function is used to fetch the result from one or more tables. The join types are normal join, inner join, left join and right join. Normal Join Join With Condition Inner Join Left Join Right Join Normal Join $this->db->select(‘tbl_user.username,tbl_user.userid,tbl_usercategory.typee’); $this->db->from(‘tbl_user’); $this->db->join(‘tbl_usercategory’,’tbl_usercategory.usercategoryid=tbl_user.usercategoryid’); $query=$this->db->get(); $data=$query->result_array(); SELECT `tbl_user`.`username`, `tbl_user`.`userid`, `tbl_usercategory`.`type` FROM (`tbl_user`) JOIN `tbl_usercategory` ON […]

CodeIgniter Queries

$this->db->query() Read & Write Query $this->db->simple_query() Set Prefixes For Table Set Dynamic Prefix For Table Protecting identifiers Escaping Queries (Security Practice) Query Bindings $this->db->query() To submit a query, use the following function: $this->db->query(‘YOUR QUERY HERE’); place raw SQL in the query() method $query = $this->db->query(“select * from users”); Pass query in a variable $sql = […]

CodeIgniter – Select Query

CodeIgniter ‘SELECT’ query will execute using following functions. They are $this->db->query() $this->db->query() With Query Bindings $this->db->get() $this->db->get() Select The Fields $this->db->get() With Limit $this->db->get() With Offset,Limit $this->db->get() With select, from $this->db->get() With Where, Or_Where, Where_In, or_where_in, where_not_in $this->db->get_where() $this->db->get() With Like, or_like, not_like, or_not_like $this->db->get() With group_by $this->db->get() With having $this->db->get() With Order BY $this->db->select_max() […]

CodeIgniter – Update Query

CodeIgniter ‘UPDATE’ query will execute using following functions. They are $this->db->update() $this->db->update_string() $this->db->update_batch() $this->db->update() $data = array( ‘name’ = > $_POST[‘name’] , ‘groupname’= > $_POST[‘groupname’], ‘age’ = > $_POST[‘age’] ); $this->db->where(‘id’, $_POST[‘id’]); $this->db->update(‘tbl_user’, $data); $this->db->update_string() Note: Values are automatically escaped, producing safer queries. $data = array( ‘groupname’= >$_POST[‘groupname’] ); $where = “status = ‘user'”; $str […]