Updated Database quoting, instances of Database_Query should call compile() rather than forcing __toString() to be called, so that the correct instance ($this) is always used

This commit is contained in:
Woody Gilk 2009-06-22 14:44:41 -05:00
parent 4434e15533
commit fefceb953d

View file

@ -179,6 +179,17 @@ abstract class Database {
{
return $value ? 'TRUE' : 'FALSE';
}
elseif (is_object($value))
{
if ($value instanceof Database_Query)
{
return '('.$value->compile($this).')';
}
else
{
return (string) $value;
}
}
elseif (is_array($value))
{
return implode(', ', array_map(array($this, __FUNCION__), $value));
@ -187,17 +198,6 @@ abstract class Database {
{
return (int) $value;
}
elseif (is_object($value))
{
if ($value instanceof Database_Query)
{
return '('.$value.')';
}
else
{
return (string) $value;
}
}
// SQL standard is to use single-quotes for all values
return '\''.$this->escape($value).'\'';
@ -219,8 +219,8 @@ abstract class Database {
{
if ($value instanceof Database_Query)
{
// Make the identifier a sub-query
return '('.$value.')';
// Compile the sub-query using the current database
return '('.$value->compile($this).')';
}
else
{