1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-16 19:14:17 +02:00

- removed 'FIELD_' from dibi data types

This commit is contained in:
David Grudl
2009-03-16 06:48:27 +00:00
parent a9afe1e397
commit 5946b7e1f6
16 changed files with 121 additions and 112 deletions

View File

@@ -201,15 +201,15 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::FIELD_BINARY:
case dibi::TEXT:
case dibi::BINARY:
return "'" . str_replace("'", "''", $value) . "'";
case dibi::IDENTIFIER:
@@ -217,13 +217,13 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
$value = str_replace(array('[', ']'), array('[[', ']]'), $value);
return '[' . str_replace('.', '].[', $value) . ']';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? -1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date("'Y-m-d'", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("'Y-m-d H:i:s'", $value);
default:
@@ -236,7 +236,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/

View File

@@ -201,15 +201,15 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::FIELD_BINARY:
case dibi::TEXT:
case dibi::BINARY:
return "'" . str_replace("'", "''", $value) . "'";
case dibi::IDENTIFIER:
@@ -217,13 +217,13 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
$value = str_replace(array('[', ']'), array('[[', ']]'), $value);
return '[' . str_replace('.', '].[', $value) . ']';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? -1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date("'Y-m-d'", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("'Y-m-d H:i:s'", $value);
default:
@@ -236,7 +236,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/

View File

@@ -273,17 +273,17 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::TEXT:
return "'" . mysql_real_escape_string($value, $this->connection) . "'";
case dibi::FIELD_BINARY:
case dibi::BINARY:
return "_binary'" . mysql_real_escape_string($value, $this->connection) . "'";
case dibi::IDENTIFIER:
@@ -291,13 +291,13 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
$value = str_replace('`', '``', $value);
return '`' . str_replace('.', '`.`', $value) . '`';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? 1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date("'Y-m-d'", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("'Y-m-d H:i:s'", $value);
default:
@@ -310,7 +310,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/

View File

@@ -257,30 +257,30 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::TEXT:
return "'" . mysqli_real_escape_string($this->connection, $value) . "'";
case dibi::FIELD_BINARY:
case dibi::BINARY:
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
case dibi::IDENTIFIER:
$value = str_replace('`', '``', $value);
return '`' . str_replace('.', '`.`', $value) . '`';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? 1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date("'Y-m-d'", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("'Y-m-d H:i:s'", $value);
default:
@@ -293,7 +293,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/
@@ -461,7 +461,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
*/
public function getColumns($table)
{
/*$table = $this->escape($table, dibi::FIELD_TEXT);
/*$table = $this->escape($table, dibi::TEXT);
$this->query("
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
@@ -494,7 +494,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
*/
public function getIndexes($table)
{
/*$table = $this->escape($table, dibi::FIELD_TEXT);
/*$table = $this->escape($table, dibi::TEXT);
$this->query("
SELECT *
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE

View File

@@ -208,28 +208,28 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::FIELD_BINARY:
case dibi::TEXT:
case dibi::BINARY:
return "'" . str_replace("'", "''", $value) . "'";
case dibi::IDENTIFIER:
$value = str_replace(array('[', ']'), array('[[', ']]'), $value);
return '[' . str_replace('.', '].[', $value) . ']';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? -1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date("#m/d/Y#", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("#m/d/Y H:i:s#", $value);
default:
@@ -242,7 +242,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/

View File

@@ -208,15 +208,15 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::FIELD_BINARY:
case dibi::TEXT:
case dibi::BINARY:
return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested
case dibi::IDENTIFIER:
@@ -224,13 +224,13 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
$value = str_replace('"', '""', $value);
return '"' . str_replace('.', '"."', $value) . '"';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? 1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date("U", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("U", $value);
default:
@@ -243,7 +243,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/

View File

@@ -226,17 +226,17 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::TEXT:
return $this->connection->quote($value, PDO::PARAM_STR);
case dibi::FIELD_BINARY:
case dibi::BINARY:
return $this->connection->quote($value, PDO::PARAM_LOB);
case dibi::IDENTIFIER:
@@ -266,13 +266,13 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
return $value;
}
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $this->connection->quote($value, PDO::PARAM_BOOL);
case dibi::FIELD_DATE:
case dibi::DATE:
return date("'Y-m-d'", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("'Y-m-d H:i:s'", $value);
default:
@@ -285,7 +285,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/

View File

@@ -233,21 +233,21 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::TEXT:
if ($this->escMethod) {
return "'" . pg_escape_string($this->connection, $value) . "'";
} else {
return "'" . pg_escape_string($value) . "'";
}
case dibi::FIELD_BINARY:
case dibi::BINARY:
if ($this->escMethod) {
return "'" . pg_escape_bytea($this->connection, $value) . "'";
} else {
@@ -264,13 +264,13 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
return substr($value, 0, $a) . '."' . str_replace('"', '""', substr($value, $a + 1)) . '"';
}
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? 'TRUE' : 'FALSE';
case dibi::FIELD_DATE:
case dibi::DATE:
return date("'Y-m-d'", $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date("'Y-m-d H:i:s'", $value);
default:
@@ -283,14 +283,14 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/
public function unescape($value, $type)
{
switch ($type) {
case dibi::FIELD_BINARY:
case dibi::BINARY:
return pg_unescape_bytea($value);
default:
@@ -438,7 +438,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
*/
public function getColumns($table)
{
$_table = $this->escape($table, dibi::FIELD_TEXT);
$_table = $this->escape($table, dibi::TEXT);
$this->query("
SELECT indkey
FROM pg_class
@@ -480,7 +480,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
*/
public function getIndexes($table)
{
$_table = $this->escape($table, dibi::FIELD_TEXT);
$_table = $this->escape($table, dibi::TEXT);
$this->query("
SELECT ordinal_position, column_name
FROM information_schema.columns

View File

@@ -220,18 +220,18 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/**
* Encodes data for use in an SQL statement.
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, ...)
* @param string type (dibi::TEXT, dibi::BOOL, ...)
* @return string encoded value
* @throws InvalidArgumentException
*/
public function escape($value, $type)
{
switch ($type) {
case dibi::FIELD_TEXT:
case dibi::FIELD_BINARY:
case dibi::TEXT:
case dibi::BINARY:
return "'" . sqlite_escape_string($value) . "'";
/*case dibi::FIELD_BINARY: // SQLite 3
/*case dibi::BINARY: // SQLite 3
static $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
$value = (string) $value;
$len = strlen($value);
@@ -244,13 +244,13 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
case dibi::IDENTIFIER:
return '[' . str_replace('.', '].[', strtr($value, '[]', ' ')) . ']';
case dibi::FIELD_BOOL:
case dibi::BOOL:
return $value ? 1 : 0;
case dibi::FIELD_DATE:
case dibi::DATE:
return date($this->fmtDate, $value);
case dibi::FIELD_DATETIME:
case dibi::DATETIME:
return date($this->fmtDateTime, $value);
default:
@@ -263,7 +263,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::FIELD_BINARY)
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/