Posts

Showing posts with the label codeigniter

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 ; } }

CI4 (Codeigniter 4) redirect function or method

as per CI 4 use return redirect()->to( 'url' ); if you are using route then use return redirect()->route( 'named_route' );

custom library creation in codeigniter 4 in hindi

Image

codeigniter custom helper creation in hindi

Image

Codeigniter 4 Installation and and Setup | Hindi Expanation

Image

Multi Vendor company employee record Application with Codeigniter 3 in H...

Image

Join and where condition in codeigniter

Image
  It's been a while since I wrote CI, but as per this docs page , your solution might look like this: $this ->db->select( '*' ); $this ->db->from( 'table1' ); $this ->db->join( 'table2' , 'table1.col1 = table2.col1' ); $this ->db->where( 'table1.col1' , 2 ); $query = $this ->db->get(); note this answer is in no way to be construed as an endorsement of working with Code Igniter ;-)

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 >  

Logout Function in PHP

Image
   This is for Codeigniter :- function logout ( ) { $user_data = $this ->session->all_userdata(); foreach ($user_data as $key => $value) { $this ->session->unset_userdata($key); } $this ->session->sess_destroy(); /////Here you have to write redirect url example : redirect("login");   }     This is for Core PHP:- function logout ( ) { session_start();  $_SESSION['email']=""; /// Here we are showing example to set empty to session key's value  session_destroy(); /////Here you have to write redirect url example : header("Location: login.php");    }  

Base URL Setting in Codeigniter

Copy below code and paste inside the config.php file in Codeigniter . You will get this file in Application/Config/config.php  $config['base_url'] = $config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ?  "https" : "http")."://".$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);