Welcome Guest, Not a member yet? Register   Sign In
database problem, and really searching for a fix

hi guys,

I'm having a serious problem. I need to expand the CI_DB_driver class to add an extra escape option to the escape funtion.
I'm currently using the this->db->insert() funtion with an dynamic array with kolumn names and values (multidimensional, but that is allready fixed) but some of the column values are subqueries, so the escape funtion will handle the subquery as a string and not as a query.
I'm allready fixing this with a preg_match on the array, but I need to 'unpack' the array and repacking it. But CI is allready doing this in the CI_DB_driver class.
My problem is, I need to write around 100 extra lines of code because I can't expand that class. If I could expand it, I only would have to write around 3 lines of code.
So, anybody knowns how to expand that class? B.t.w: class is the file "system/database/db_driver.php"

Oh and i cant use a join or something else because the data to be inserted is from remote xml files, normalized, and read in php through objects and arrays.


Hi Guys,

I have solved this problem, not by extending the CI_DB_driver class but by extracting the array and extra using the $this->db->set() function with a preg_match on the value from the array.

Here my sollution:
foreach($dataArray as $kolumn => $value) {
                if(preg_match("/select (.*) from (.*)/i", trim($value)) > 0){
                    $this->db->set($kolumn, $value, FALSE);
                    $this->db->set($kolumn, $value);
// $tablename was previously declared by the masterArray

Theme © iAndrew 2016 - Forum software by © MyBB