CodeIgniter Forums
How to call mysql stored functions - 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: How to call mysql stored functions (/showthread.php?tid=23191)



How to call mysql stored functions - El Forum - 10-03-2009

[eluser]Unknown[/eluser]
Hello, everyone.

I want call mysql stored function with return value (result of some calculation, summ for example).

I think like this but it doesn't work;

$sql = "? = summ(?, ?)";
$query = $this->db->query($sql, array( NULL, 4, 5));
$row = $query->row();


How I can get returning value?


How to call mysql stored functions - El Forum - 10-03-2009

[eluser]Unknown[/eluser]
I find answer:

$sql = "select summ(?, ?) as result";
$query = $this->db->query($sql, array( 4, 5));
$result = $query->row()->result;

I want to write some php file that will be contain all my database function.
I dont know how it better to do. Please give me advice...

May be create helper, or my be use models...


How to call mysql stored functions - El Forum - 10-03-2009

[eluser]InsiteFX[/eluser]
You shold be putting your data in a model.

Enjoy
InsiteFX