mirror of
https://github.com/dg/dibi.git
synced 2025-08-08 15:16:58 +02:00
typos & whitespace
This commit is contained in:
@@ -54,7 +54,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
private $buffered;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws DibiNotSupportedException
|
||||
*/
|
||||
@@ -66,13 +65,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'])) {
|
||||
@@ -80,12 +78,14 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
|
||||
} else {
|
||||
// default values
|
||||
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
||||
if (!isset($config['timezone'])) $config['timezone'] = date('P');
|
||||
if (!isset($config['username'])) $config['username'] = ini_get('mysqli.default_user');
|
||||
if (!isset($config['password'])) $config['password'] = ini_get('mysqli.default_pw');
|
||||
if (!isset($config['socket'])) $config['socket'] = ini_get('mysqli.default_socket');
|
||||
if (!isset($config['port'])) $config['port'] = NULL;
|
||||
$config += array(
|
||||
'charset' => 'utf8',
|
||||
'timezone' => date('P'),
|
||||
'username' => ini_get('mysqli.default_user'),
|
||||
'password' => ini_get('mysqli.default_pw'),
|
||||
'socket' => ini_get('mysqli.default_socket'),
|
||||
'port' => NULL,
|
||||
);
|
||||
if (!isset($config['host'])) {
|
||||
$host = ini_get('mysqli.default_host');
|
||||
if ($host) {
|
||||
@@ -141,7 +141,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects from a database.
|
||||
* @return void
|
||||
@@ -152,7 +151,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Executes the SQL query.
|
||||
* @param string SQL statement.
|
||||
@@ -172,7 +170,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves information about the most recently executed query.
|
||||
* @return array
|
||||
@@ -181,7 +178,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];
|
||||
@@ -190,7 +189,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
|
||||
@@ -201,7 +199,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
|
||||
@@ -212,7 +209,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Begins a transaction (if supported).
|
||||
* @param string optional savepoint name
|
||||
@@ -225,7 +221,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Commits statements in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -238,7 +233,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rollback changes in a transaction.
|
||||
* @param string optional savepoint name
|
||||
@@ -251,7 +245,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection resource.
|
||||
* @return mysqli
|
||||
@@ -262,7 +255,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the connection reflector.
|
||||
* @return IDibiReflector
|
||||
@@ -273,7 +265,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Result set driver factory.
|
||||
* @param mysqli_result
|
||||
@@ -287,11 +278,9 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* SQL ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes data for use in a SQL statement.
|
||||
* @param mixed value
|
||||
@@ -302,31 +291,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
|
||||
@@ -340,7 +328,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decodes data from result set.
|
||||
* @param string value
|
||||
@@ -357,29 +344,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
|
||||
@@ -390,7 +371,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows in a result set.
|
||||
* @return int
|
||||
@@ -404,7 +384,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
|
||||
@@ -416,7 +395,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Moves cursor position without fetching row.
|
||||
* @param int the 0-based cursor pos to seek to
|
||||
@@ -432,7 +410,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Frees the resources allocated for this result set.
|
||||
* @return void
|
||||
@@ -444,7 +421,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns metadata for all columns in a result set.
|
||||
* @return array
|
||||
@@ -478,7 +454,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the result set resource.
|
||||
* @return mysqli_result
|
||||
|
Reference in New Issue
Block a user