Articles → PHP CODEIGNITER → Active Records In Codeigniter

Active Records In Codeigniter






Purpose





Example




<?php
class mymodel extends CI_Model
{
    public function GetUsers()
    {
        $this
            ->load
            ->database();

        $q = $this
            ->db
            ->get_where("Class", array(
            'classCode' => 'LKG'
        ));
        $result = $q->result();

        return $result;
    }
}






Picture showing the output of active records in codeigniter

Click to Enlarge


Advantages Of Active Record




  1. Less code writing.
  2. Database independent.
  3. Safe against SQL injection.



  4. Posted By  -  Karan Gupta
     
    Posted On  -  Friday, July 17, 2020

    Query/Feedback


    Your Email Id  
     
    Subject 
     
    Query/FeedbackCharacters remaining 250