mirror of
https://github.com/dg/dibi.git
synced 2025-08-13 01:24:06 +02:00
typos & whitespace
This commit is contained in:
@@ -2,11 +2,7 @@
|
||||
|
||||
/**
|
||||
* This file is part of the "dibi" - smart database abstraction layer.
|
||||
*
|
||||
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the file license.txt that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +38,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
private $row = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws DibiNotSupportedException
|
||||
*/
|
||||
@@ -54,13 +49,12 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Connects to a database.
|
||||
* @return void
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function connect(array &$config)
|
||||
public function connect(array & $config)
|
||||
{
|
||||
if (isset($config['resource'])) {
|
||||
$this->connection = $config['resource'];
|
||||
@@ -83,7 +77,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects from a database.
|
||||
* @return void
|
||||
@@ -94,7 +87,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Executes the SQL query.
|
||||
* @param string SQL statement.
|
||||
@@ -116,7 +108,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||
* @return int|FALSE number of rows or FALSE on error
|
||||
@@ -127,7 +118,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||
* @return int|FALSE int on success or FALSE on failure
|
||||
@@ -138,7 +128,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Begins a transaction (if supported).
|
||||
* @param string optional savepoint name
|
||||
@@ -153,7 +142,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Commits statements in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -169,7 +157,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rollback changes in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -185,7 +172,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is in transaction?
|
||||
* @return bool
|
||||
@@ -196,7 +182,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection resource.
|
||||
* @return mixed
|
||||
@@ -207,7 +192,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection reflector.
|
||||
* @return IDibiReflector
|
||||
@@ -218,7 +202,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Result set driver factory.
|
||||
* @param resource
|
||||
@@ -232,11 +215,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* SQL ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes data for use in a SQL statement.
|
||||
* @param mixed value
|
||||
@@ -247,29 +228,28 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
public function escape($value, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case dibi::TEXT:
|
||||
case dibi::BINARY:
|
||||
return "'" . str_replace("'", "''", $value) . "'";
|
||||
case dibi::TEXT:
|
||||
case dibi::BINARY:
|
||||
return "'" . str_replace("'", "''", $value) . "'";
|
||||
|
||||
case dibi::IDENTIFIER:
|
||||
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
||||
case dibi::IDENTIFIER:
|
||||
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
||||
|
||||
case dibi::BOOL:
|
||||
return $value ? 1 : 0;
|
||||
case dibi::BOOL:
|
||||
return $value ? 1 : 0;
|
||||
|
||||
case dibi::DATE:
|
||||
return $value instanceof DateTime ? $value->format("#m/d/Y#") : date("#m/d/Y#", $value);
|
||||
case dibi::DATE:
|
||||
return $value instanceof DateTime ? $value->format("#m/d/Y#") : date("#m/d/Y#", $value);
|
||||
|
||||
case dibi::DATETIME:
|
||||
return $value instanceof DateTime ? $value->format("#m/d/Y H:i:s#") : date("#m/d/Y H:i:s#", $value);
|
||||
case dibi::DATETIME:
|
||||
return $value instanceof DateTime ? $value->format("#m/d/Y H:i:s#") : date("#m/d/Y H:i:s#", $value);
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException('Unsupported type.');
|
||||
default:
|
||||
throw new InvalidArgumentException('Unsupported type.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes string for use in a LIKE statement.
|
||||
* @param string
|
||||
@@ -283,7 +263,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decodes data from result set.
|
||||
* @param string value
|
||||
@@ -300,30 +279,26 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Injects LIMIT/OFFSET to the SQL query.
|
||||
* @param string &$sql The SQL query that will be modified.
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return void
|
||||
*/
|
||||
public function applyLimit(&$sql, $limit, $offset)
|
||||
public function applyLimit(& $sql, $limit, $offset)
|
||||
{
|
||||
// offset support is missing
|
||||
if ($limit >= 0) {
|
||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
||||
}
|
||||
|
||||
if ($offset) throw new DibiNotSupportedException('Offset is not implemented in driver odbc.');
|
||||
if ($offset) {
|
||||
throw new DibiNotSupportedException('Offset is not implemented in driver odbc.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* result set ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Automatically frees the resources allocated for this result set.
|
||||
* @return void
|
||||
@@ -334,7 +309,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows in a result set.
|
||||
* @return int
|
||||
@@ -346,7 +320,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||
* @param bool TRUE for associative array, FALSE for numeric
|
||||
@@ -358,7 +331,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
return odbc_fetch_array($this->resultSet, ++$this->row);
|
||||
} else {
|
||||
$set = $this->resultSet;
|
||||
if (!odbc_fetch_row($set, ++$this->row)) return FALSE;
|
||||
if (!odbc_fetch_row($set, ++$this->row)) {
|
||||
return FALSE;
|
||||
}
|
||||
$count = odbc_num_fields($set);
|
||||
$cols = array();
|
||||
for ($i = 1; $i <= $count; $i++) $cols[] = odbc_result($set, $i);
|
||||
@@ -367,7 +342,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Moves cursor position without fetching row.
|
||||
* @param int the 0-based cursor pos to seek to
|
||||
@@ -380,7 +354,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Frees the resources allocated for this result set.
|
||||
* @return void
|
||||
@@ -392,7 +365,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all columns in a result set.
|
||||
* @return array
|
||||
@@ -413,7 +385,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the result set resource.
|
||||
* @return mixed
|
||||
@@ -425,11 +396,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* IDibiReflector ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns list of tables.
|
||||
* @return array
|
||||
@@ -451,7 +420,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all columns in a table.
|
||||
* @param string
|
||||
@@ -478,7 +446,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all indexes in a table.
|
||||
* @param string
|
||||
@@ -490,7 +457,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all foreign keys in a table.
|
||||
* @param string
|
||||
|
Reference in New Issue
Block a user