php - CodeIgniter modifications extending database drivers for using them with UNION queries -
my goal use union queries in codeigniter active record.
some people suggested me use method $this->db->last_query(); queries want, combining union.
problem $this->db->from(); method used in mysql driver in active record uses parenthesis around clause (ex: select * ('table') ) , prevents me use union.
so checked again , found modify _from_tables function defined in the
system/database/drivers/mysql/mysql_driver.php
i changed code :
function _from_tables($tables) { if ( ! is_array($tables)) { $tables = array($tables); } return '('.implode(', ', $tables).')'; }
to :
function _from_tables($tables) { if ( ! is_array($tables)) { $tables = array($tables); } return implode(', ', $tables); }
but if asked question here on how extend ci mysql driver (in fact, want replace method custom one) : codeigniter hooks active record library , proposed ask new question.
so 1 user proposed add 2 files, did, in folders:
application/libraries/my_db_mysql_driver.php application/core/my_loader.php
i these errors while using method :
php error encountered severity: 8192 message: assigning return value of new reference deprecated filename: core/my_loader.php line number: 32
so modified script gave me (you can see @ https://github.com/ellislab/codeigniter/wiki/extending-database-drivers) deleting & in :
$db =& new $my_driver(get_object_vars($db));
i following error :
fatal error: call undefined method my_db_mysql_driver::where() in \system\libraries\session.php
if has done without tweaking system folder, please :(
Comments
Post a Comment