1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-19 12:21:46 +02:00

- DibiDriver::format splitted into escape() & unescape()

- added DibiConnection::unescape
- DibiPostgreDriver support escaping & unescaping BYTEA type
This commit is contained in:
David Grudl
2008-05-25 18:44:43 +00:00
parent 3728b16a21
commit c23bf15a3d
14 changed files with 401 additions and 133 deletions

View File

@@ -372,15 +372,30 @@ class DibiConnection extends /*Nette::*/Object
/**
* Escapes the string.
* Encodes data for use in an SQL statement.
*
* @param string unescaped string
* @return string escaped and optionally quoted string
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @return string escaped and quoted string
*/
public function escape($value)
public function escape($value, $type = dibi::FIELD_TEXT)
{
$this->connect(); // MySQL & PDO require connection
return $this->driver->format($value, dibi::FIELD_TEXT);
return $this->driver->escape($value, $type);
}
/**
* Decodes data from resultset.
*
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @return string decoded value
*/
public function unescape($value, $type = dibi::FIELD_BINARY)
{
return $this->driver->unescape($value, $type);
}
@@ -393,7 +408,7 @@ class DibiConnection extends /*Nette::*/Object
*/
public function delimite($value)
{
return $this->driver->format($value, dibi::IDENTIFIER);
return $this->driver->escape($value, dibi::IDENTIFIER);
}