PostGreSQL $this->db->insert_id() |
[eluser]Greg Aker[/eluser]
Hey guys, I have run into a problem with postgres 7.4.7 and getting the insert_id properly returned. I came up with a workaround, but it's not going to work with php4. I thought I'd share my findings and see if anyone can add to it. ./system/database/drivers/postgre/postgre_driver.php _version() was not working for me. a var_dump or print_r gave me the value of "S". so I changed it to: Code: function _version() So that is where the php4 vs php5 issues come in to play. Then, in the MSSQL driver, there is a function to grab the major version. I used a modified version of that to give me the major and minor version, and this is what I came up with. Code: function _parse_version($version) The I changed the top of insert_id() to: Code: function insert_id() So that's what I have and it's working nicely for me on pg 7.4.7. I'd like to see what you guys think, and I appreciate any feedback. Thanks, -greg
[eluser]Pascal Kriete[/eluser]
I don't have a postgre setup to test on, but that looks good to me. It could check for php5 and return 0 for php 4 (anything smaller than 8 should work). A quick look at how cake and zend do it makes me think that CI might to be taking the complicated (read: übercompatible) route again. The other two essentially do: Code: $seq = $column ? $table.'_'.$column.'_seq' : $table.'_seq'; |
Welcome Guest, Not a member yet? Register Sign In |