• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
database problem, and really searching for a fix

#1
[eluser]Unknown[/eluser]
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.

Thanks..

#2
[eluser]Unknown[/eluser]
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:
Code:
foreach($dataArray as $kolumn => $value) {
                if(preg_match("/select (.*) from (.*)/i", trim($value)) > 0){
                    $this->db->set($kolumn, $value, FALSE);
  }else{
                    $this->db->set($kolumn, $value);
                }
            }
// $tablename was previously declared by the masterArray
$this->db->insert($tablename);



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.