CodeIgniter Forums
Error handling when using database call_function() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Error handling when using database call_function() (/showthread.php?tid=53986)



Error handling when using database call_function() - El Forum - 08-17-2012

[eluser]tlloyduk[/eluser]
Hi All,

I hope you can help me Smile

I am using the Postgres driver and want to call pg_query and pg_fetch_all directly, so I found the call_function() function which does what I need perfectly.

My code:

Code:
$db_id = $this->db->conn_id;
$query = $this->db->call_function('query', $db_id, "SELECT * FROM " . $table);
$result = $this->db->call_function("fetch_all", $query);

My question:

How do I trap an error that is returned by pg_query or pg_fetch_all within the call_function() wrapper? For example if $table contains a reference to an invalid table, a PHP Warning message is displayed in the browser. I want to be able to trap that in advance and handle it myself.

Any ideas?

Thanks,

Tim