CodeIgniter Forums
Active Record Postgres stored procedure not working with 1 parameter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Active Record Postgres stored procedure not working with 1 parameter (/thread-8726.html)



Active Record Postgres stored procedure not working with 1 parameter - El Forum - 05-29-2008

[eluser]redguy[/eluser]
I have several plpgsql stored procedures in my database:
1) add_hit (integer, integer, integer)
2) add_score (integer, integer)
3) add_start (integer)

I call function 1 successfully with:
Code:
$result = $this->db->get("add_hit($sid,$qid,$aid)")->row_array();
The following SQL is generated:
Code:
SELECT * FROM add_hit(1,4,11)

I call function 2 successfully with:
Code:
$result = $this->db->get("add_score($sid,$qid)")->row_array();
The following SQL is generated:
Code:
SELECT * FROM add_score(1,34)

But when I call function 3 like that:
Code:
$result = $this->db->get("add_start($sid)")->row_array();
The following SQL is generated:
Code:
SELECT * FROM add_start("1")


It seems that CI adds quotes around the parameter. And while PHP allows a String to become an integer, Postgres doesn't. So I get an error. I solved this by running a manual query like:
Code:
$sql = "SELECT * FROM add_start($sid)";
$result = $this->db->query($sql)->row_array();
Which does the job.

I can't use the call_function function with Postgres, so I'm wondering if this is an AR bug?