mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +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.
|
||||
*/
|
||||
|
||||
|
||||
@@ -48,7 +44,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
private $dbcharset, $charset;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws DibiNotSupportedException
|
||||
*/
|
||||
@@ -60,13 +55,12 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Connects to a database.
|
||||
* @return void
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function connect(array &$config)
|
||||
public function connect(array & $config)
|
||||
{
|
||||
DibiConnection::alias($config, 'database', 'file');
|
||||
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
||||
@@ -95,7 +89,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects from a database.
|
||||
* @return void
|
||||
@@ -106,7 +99,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Executes the SQL query.
|
||||
* @param string SQL statement.
|
||||
@@ -134,7 +126,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||
* @return int|FALSE number of rows or FALSE on error
|
||||
@@ -145,7 +136,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||
* @return int|FALSE int on success or FALSE on failure
|
||||
@@ -156,7 +146,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Begins a transaction (if supported).
|
||||
* @param string optional savepoint name
|
||||
@@ -169,7 +158,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Commits statements in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -182,7 +170,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rollback changes in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -195,7 +182,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection resource.
|
||||
* @return mixed
|
||||
@@ -206,7 +192,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection reflector.
|
||||
* @return IDibiReflector
|
||||
@@ -217,7 +202,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Result set driver factory.
|
||||
* @param resource
|
||||
@@ -231,11 +215,9 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* SQL ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes data for use in a SQL statement.
|
||||
* @param mixed value
|
||||
@@ -246,29 +228,28 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
public function escape($value, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case dibi::TEXT:
|
||||
case dibi::BINARY:
|
||||
return "'" . sqlite_escape_string($value) . "'";
|
||||
case dibi::TEXT:
|
||||
case dibi::BINARY:
|
||||
return "'" . sqlite_escape_string($value) . "'";
|
||||
|
||||
case dibi::IDENTIFIER:
|
||||
return '[' . strtr($value, '[]', ' ') . ']';
|
||||
case dibi::IDENTIFIER:
|
||||
return '[' . strtr($value, '[]', ' ') . ']';
|
||||
|
||||
case dibi::BOOL:
|
||||
return $value ? 1 : 0;
|
||||
case dibi::BOOL:
|
||||
return $value ? 1 : 0;
|
||||
|
||||
case dibi::DATE:
|
||||
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
||||
case dibi::DATE:
|
||||
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
||||
|
||||
case dibi::DATETIME:
|
||||
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
||||
case dibi::DATETIME:
|
||||
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException('Unsupported type.');
|
||||
default:
|
||||
throw new InvalidArgumentException('Unsupported type.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes string for use in a LIKE statement.
|
||||
* @param string
|
||||
@@ -281,7 +262,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decodes data from result set.
|
||||
* @param string value
|
||||
@@ -298,26 +278,21 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if ($limit < 0 && $offset < 1) return;
|
||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||
if ($limit >= 0 || $offset > 0) {
|
||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* result set ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows in a result set.
|
||||
* @return int
|
||||
@@ -331,7 +306,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||
* @param bool TRUE for associative array, FALSE for numeric
|
||||
@@ -355,7 +329,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Moves cursor position without fetching row.
|
||||
* @param int the 0-based cursor pos to seek to
|
||||
@@ -371,7 +344,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Frees the resources allocated for this result set.
|
||||
* @return void
|
||||
@@ -382,7 +354,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all columns in a result set.
|
||||
* @return array
|
||||
@@ -405,7 +376,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the result set resource.
|
||||
* @return mixed
|
||||
@@ -416,11 +386,9 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* user defined functions ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Registers an user defined function for use in SQL statements.
|
||||
* @param string function name
|
||||
@@ -434,7 +402,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Registers an aggregating user defined function for use in SQL statements.
|
||||
* @param string function name
|
||||
|
Reference in New Issue
Block a user