Welcome Guest, Not a member yet? Register   Sign In
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

(This post was last modified: 06-02-2018, 04:27 AM by InsiteFX.)

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




Theme © iAndrew 2016 - Forum software by © MyBB