• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Model database Query

#1
Hi, I'm using this code codeigniter 3.I try ci4 this code but not working.How work this code ci4?

Code:
public function give($from,$where=array()){
    $giveme = $this->db->from($from)->where($where)->get()->row_array();
    return $giveme;
}
Reply

#2
It would be something like this:

PHP Code:
public function give($from,$where=array())
{
    $db = \Config\Database::connect();
    $builder $db->table($from);
    
    $giveme 
$builder->from($from)->where($where)->get()->getResultArray();

    return $giveme;


Did not have the time to test it, but give it a go.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
If you use CI4 model, simply set the protected variables for $table, $returnType etc. then create function in the model:

PHP Code:
public function give$where=[] ) 
{
   return 
$this->where$where )->findAll();

Dirk B.
No SEO spam - see forum guidelines
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.