CodeIgniter Forums
$this->dbutil->backup() does not protect table names - 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: $this->dbutil->backup() does not protect table names (/showthread.php?tid=19115)



$this->dbutil->backup() does not protect table names - El Forum - 05-28-2009

[eluser]davidbehler[/eluser]
I have a table called 'group' and using
Code:
$this->dbutil->backup()
I get an SQL error:
Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group' at line 1

SELECT * FROM group

That's caused by not protecting the table name using backticks as 'group' is a reserved name in SQL.

For now I will have to create my own backup function that does not have this flaw, but I hope this will be fixed soon and I can use the CI function againg Smile


$this->dbutil->backup() does not protect table names - El Forum - 05-28-2009

[eluser]davidbehler[/eluser]
This can be easily achieved by adding this on line 98 in database/drivers/mysql/mysql_utility.php
Code:
$table = $this->db->protect_identifiers($table);



$this->dbutil->backup() does not protect table names - El Forum - 03-30-2010

[eluser]verynewtothis[/eluser]
Thanks waldmeister!
Big help Smile