Welcome Guest, Not a member yet? Register   Sign In
CI 3 list_fields() problem
#1

Goodmorning everyone,

I have this problem with list_fields ()

Simple example:

PHP Code:
$query $this->db->query('SELECT field_1, field_2 FROM table_name');

$fields $query->list_fields(); 

it works...

instead...

PHP Code:
$query $this->db->select('field_1, filed_2')
 
                 ->get('table_name')
 
                 ->result(); 


does not work

Message: Call to a member function list_fields() on a non-object

some idea?

Thanks
Reply
#2

list_fields() is a method of the CI_DB_result class. In the code that follows $query is an array of objects that result() returned

PHP Code:
$query $this->db
       
->select('field_1, filed_2')
       ->get('table_name')
       ->result(); 

You're probably needing something like this

PHP Code:
$query $this->db
       
->select('field_1, filed_2')
       ->get('table_name');

$fields $query->list_fields(); 
$results  $query->result(); 
Reply
#3

(09-19-2018, 09:56 AM)dave friend Wrote: list_fields() is a method of the CI_DB_result class. In the code that follows $query is an array of objects that result() returned

PHP Code:
$query $this->db
       
->select('field_1, filed_2')
       ->get('table_name')
       ->result(); 

You're probably needing something like this

PHP Code:
$query $this->db
       
->select('field_1, filed_2')
       ->get('table_name');

$fields $query->list_fields(); 
$results  $query->result(); 

perfect, I had made a bit of confusion, it works perfectly, thank you very much
Reply




Theme © iAndrew 2016 - Forum software by © MyBB