• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create query in Librries

#1
How to use database library in libraries?

I try this:

PHP Code:
<?php


namespace App\Libraries;

class 
Test   {
        
   
    
public function test()
        {
           
        $db 
= \Config\Database::connect();
        $query $db->query('SELECT * FROM test');
        $results $query->getResult();
        print_r($results);
        
        
}

Reply

#2
Did you try adding this?

PHP Code:
$error $db->error(); // Has keys 'code' and 'message' 

If there is an error it should give you the information.

You may also need to use the full namespace name.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
It's worked.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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