Normalize quote_ident method

This commit is contained in:
Timothy Warren 2012-04-10 15:43:39 -04:00
parent ace22357f6
commit b3306772f9
3 changed files with 6 additions and 22 deletions

View File

@ -23,6 +23,7 @@ abstract class DB_PDO extends PDO {
public $manip; public $manip;
protected $statement; protected $statement;
protected $escape_char = '"';
/** /**
* PDO constructor wrapper * PDO constructor wrapper
@ -172,7 +173,9 @@ abstract class DB_PDO extends PDO {
// Split each identifier by the period // Split each identifier by the period
$hiers = explode('.', $ident); $hiers = explode('.', $ident);
return '"'.implode('"."', $hiers).'"'; return $this->escape_char .
implode("{$this->escape_char}.{$this->escape_char}", $hiers) .
$this->escape_char;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -19,6 +19,8 @@
*/ */
class MySQL extends DB_PDO { class MySQL extends DB_PDO {
protected $escape_char = '`';
/** /**
* Connect to MySQL Database * Connect to MySQL Database
* *
@ -83,26 +85,5 @@ class MySQL extends DB_PDO {
{ {
return isset($this->statement) ? $this->statement->rowCount() : FALSE; return isset($this->statement) ? $this->statement->rowCount() : FALSE;
} }
// --------------------------------------------------------------------------
/**
* Surrounds the string with the databases identifier escape characters
*
* @param string $ident
* @return string
*/
public function quote_ident($ident)
{
if (is_array($ident))
{
return array_map(array($this, 'quote_ident'), $ident);
}
// Split each identifier by the period
$hiers = explode('.', $ident);
return '`'.implode('`.`', $hiers).'`';
}
} }
//End of mysql_driver.php //End of mysql_driver.php

Binary file not shown.