Posts

Showing posts with the label ci

Codeigniter (CI) index.php removing from url

Image
  <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>

Codeigniter Inner Join Example

Image
public function funcname ( $id ) { $this ->db->select( '*' ); $this ->db->from( 'Album a' ); $this ->db->join( 'Category b' , 'b.cat_id=a.cat_id' , 'left' ); $this ->db->join( 'Soundtrack c' , 'c.album_id=a.album_id' , 'left' ); $this ->db->where( 'c.album_id' , $id ); $this ->db->order_by( 'c.track_title' , 'asc' ); $query = $this ->db->get(); if ( $query ->num_rows() != 0 ) { return $query ->result_array(); } else { return false ; } }

Codeigniter (CI) Table Join

Image
    $this ->db->select( 'users.usrID, users_profiles.usrpID' ) ->from( 'users' ) ->join( 'users_profiles' , 'users.usrID = users_profiles.usrpID' ); $result = $this ->db->get();

How to get URL data in Codeigniter

Image
  This is the example for it  :-  http://websitename.com/controller_name/function_name/parameter1/parameter2/parameter3 it will return $this ->uri->segment( 1 ); // controller $this ->uri->segment( 2 ); // function To get parameter1 in codeigniter : - $this->uri->segment(3); To get parameter2 in codeigniter : - $this->uri->segment(4);  To get parameter3 in codeigniter : - $this->uri->segment(5);  

How to load model and use it in Codeigniter (CI)

Image
   Here We are loading model $this -> load -> model ( 'model_name' ); And here we are using model's method  $this -> model_name -> method ();

Pass data from controller to view - Codeigniter

Image
    Controller Part : - public function get_annunci ( ) { $query[ 'annunci' ]= $this ->user_model->annunci( $this ->email); $this ->load->view( 'main_view' ,$query); }   View Part :-    <div class =" tab - pane active " id =" annunci "> < ul > <? php print_r ($ annunci ); ?> </ ul > </ div >