php - codeigniter get postgres fieldtypes of recent query
Get the solution ↓↓↓I am using php with codeigniter. I like to run a sql query on my postgres db and I am interested not only in the result but in the field types as well.
There is the php function: pg_field_type ( resource $result , int $field_number )
that should return the information I need, but I wonder if there is a way to use it with codeigniter db class?
Versions
postgres: 9.4 codeigniter: 3.1.10
Example
$res = $this->db->query("select * from foobar);
returns me an result object like this:
CI_DB_postgre_result Object
(
[conn_id] => Resource id #2
[result_id] => Resource id #5
[result_array] => Array
(
)
[result_object] => Array
(
)
[custom_result_object] => Array
(
)
[current_row] => 0
[num_rows] =>
[row_data] =>
)
It its visual that Resource id #5 would be my resource but how to access it?
best,
d.
Answer
Solution:
$res = $this->db->query("select * from foobar);
$data = $res->result();
print_r( $data ) // will print all the rows
//return $data // will return data to the controller
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: method illuminate\database\eloquent\collection::paginate does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.