mirror of
https://github.com/dg/dibi.git
synced 2025-08-11 00:24:19 +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.
|
||||
*/
|
||||
|
||||
|
||||
@@ -54,7 +50,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
private $buffered;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws DibiNotSupportedException
|
||||
*/
|
||||
@@ -66,13 +61,12 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Connects to a database.
|
||||
* @return void
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function connect(array &$config)
|
||||
public function connect(array & $config)
|
||||
{
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
if (isset($config['resource'])) {
|
||||
@@ -138,7 +132,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects from a database.
|
||||
* @return void
|
||||
@@ -149,7 +142,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Executes the SQL query.
|
||||
* @param string SQL statement.
|
||||
@@ -169,7 +161,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves information about the most recently executed query.
|
||||
* @return array
|
||||
@@ -178,7 +169,9 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
{
|
||||
$res = array();
|
||||
preg_match_all('#(.+?): +(\d+) *#', mysqli_info($this->connection), $matches, PREG_SET_ORDER);
|
||||
if (preg_last_error()) throw new DibiPcreException;
|
||||
if (preg_last_error()) {
|
||||
throw new DibiPcreException;
|
||||
}
|
||||
|
||||
foreach ($matches as $m) {
|
||||
$res[$m[1]] = (int) $m[2];
|
||||
@@ -187,7 +180,6 @@ class DibiMySqliDriver 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
|
||||
@@ -198,7 +190,6 @@ class DibiMySqliDriver 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
|
||||
@@ -209,7 +200,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Begins a transaction (if supported).
|
||||
* @param string optional savepoint name
|
||||
@@ -222,7 +212,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Commits statements in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -235,7 +224,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rollback changes in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -248,7 +236,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection resource.
|
||||
* @return mysqli
|
||||
@@ -259,7 +246,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection reflector.
|
||||
* @return IDibiReflector
|
||||
@@ -270,7 +256,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Result set driver factory.
|
||||
* @param mysqli_result
|
||||
@@ -284,11 +269,9 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* SQL ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes data for use in a SQL statement.
|
||||
* @param mixed value
|
||||
@@ -299,31 +282,30 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
public function escape($value, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case dibi::TEXT:
|
||||
return "'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||
case dibi::TEXT:
|
||||
return "'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||
|
||||
case dibi::BINARY:
|
||||
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||
case dibi::BINARY:
|
||||
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||
|
||||
case dibi::IDENTIFIER:
|
||||
return '`' . str_replace('`', '``', $value) . '`';
|
||||
case dibi::IDENTIFIER:
|
||||
return '`' . str_replace('`', '``', $value) . '`';
|
||||
|
||||
case dibi::BOOL:
|
||||
return $value ? 1 : 0;
|
||||
case dibi::BOOL:
|
||||
return $value ? 1 : 0;
|
||||
|
||||
case dibi::DATE:
|
||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||
case dibi::DATE:
|
||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||
|
||||
case dibi::DATETIME:
|
||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||
case dibi::DATETIME:
|
||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d 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
|
||||
@@ -337,7 +319,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decodes data from result set.
|
||||
* @param string value
|
||||
@@ -354,29 +335,23 @@ class DibiMySqliDriver 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;
|
||||
|
||||
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
|
||||
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
||||
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||
if ($limit >= 0 || $offset > 0) {
|
||||
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
|
||||
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
||||
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* result set ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Automatically frees the resources allocated for this result set.
|
||||
* @return void
|
||||
@@ -387,7 +362,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows in a result set.
|
||||
* @return int
|
||||
@@ -401,7 +375,6 @@ class DibiMySqliDriver 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
|
||||
@@ -413,7 +386,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Moves cursor position without fetching row.
|
||||
* @param int the 0-based cursor pos to seek to
|
||||
@@ -429,7 +401,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Frees the resources allocated for this result set.
|
||||
* @return void
|
||||
@@ -441,7 +412,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all columns in a result set.
|
||||
* @return array
|
||||
@@ -475,7 +445,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the result set resource.
|
||||
* @return mysqli_result
|
||||
|
Reference in New Issue
Block a user