CodeIgniter Forums
Troubles with PostgreSQL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Troubles with PostgreSQL (/thread-1731.html)



Troubles with PostgreSQL - El Forum - 06-22-2007

[eluser]hrundel[/eluser]
Hi, all. I'm not long ago begin to use CodeIgniter, it's nice and light for understanding framework.
But when I face to some troubles when I try to work with postgresql.
I edited database.php as needed and when loading database library thereis no errors i.e. connecting and selecting database passed successfully, but such construction
Code:
$query = $this->db->query("SELECT * FROM some_table");
echo "<pre>";
var_dump($query);
echo "</pre>";
return empty result_array, although some_table not empty. I'm use latest version of codeigniter and version of postgresql sever is 8.0
Doe's enybody know reason of my trouble.
Thanks.


Troubles with PostgreSQL - El Forum - 06-23-2007

[eluser]optimal[/eluser]
You may have already verified this, but does your database user (Postgres role) definitely have the necessary select privileges for your table? Can your specified user select from this table outside of PHP/CI?


Troubles with PostgreSQL - El Forum - 06-23-2007

[eluser]hrundel[/eluser]
Quote:Can your specified user select from this table outside of PHP/CI?
Yes, I run such select query from pgAdmin where I connected to postgres server using the same user as in CI. And pgadmin sql window show results of such query i.e. my table is not empty.


Troubles with PostgreSQL - El Forum - 06-25-2007

[eluser]optimal[/eluser]
You could also try creating a simple test page to see if you can retrieve your query results using PHP without the CI framework (if only to eliminate that as a potential source of the problem).


Troubles with PostgreSQL - El Forum - 06-25-2007

[eluser]hrundel[/eluser]
Problem solved, thanks all.
var_dump($query) showed that result is empty, but $query->num_rows() worked. And following construction also worked:
foreach($query->result() as $row)
echo $row->field_name