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

fixed phpDoc

This commit is contained in:
David Grudl
2017-06-09 21:21:19 +02:00
parent d9628f933d
commit 80ac569621
21 changed files with 340 additions and 85 deletions

View File

@@ -63,7 +63,7 @@ class Panel implements Tracy\IBarPanel
/**
* Returns blue-screen custom tab.
* @return mixed
* @return array|NULL
*/
public static function renderException($e)
{
@@ -78,7 +78,7 @@ class Panel implements Tracy\IBarPanel
/**
* Returns HTML code for custom tab. (Tracy\IBarPanel)
* @return mixed
* @return string
*/
public function getTab()
{
@@ -96,7 +96,7 @@ class Panel implements Tracy\IBarPanel
/**
* Returns HTML code for custom panel. (Tracy\IBarPanel)
* @return mixed
* @return string|NULL
*/
public function getPanel()
{

View File

@@ -225,7 +225,7 @@ class Connection
/**
* Generates (translates) and executes SQL query.
* @param array|mixed one or more arguments
* @return Result|int result set object (if any)
* @return Result|int result set or number of affected rows
* @throws Exception
*/
final public function query($args)
@@ -303,7 +303,7 @@ class Connection
/**
* Executes the SQL query.
* @param string SQL statement.
* @return Result|int result set object (if any)
* @return Result|int result set or number of affected rows
* @throws Exception
*/
final public function nativeQuery($sql)
@@ -473,7 +473,7 @@ class Connection
/**
* @param string column name
* @param mixed column name
* @return Fluent
*/
public function select($args)
@@ -555,7 +555,7 @@ class Connection
/**
* Executes SQL query and fetch result - shortcut for query() & fetch().
* @param array|mixed one or more arguments
* @return Row|bool
* @return Row|FALSE
* @throws Exception
*/
public function fetch($args)
@@ -581,7 +581,7 @@ class Connection
/**
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
* @param array|mixed one or more arguments
* @return string|bool
* @return mixed
* @throws Exception
*/
public function fetchSingle($args)

View File

@@ -40,10 +40,10 @@ class DataSource implements IDataSource
/** @var array */
private $conds = [];
/** @var int */
/** @var int|NULL */
private $offset;
/** @var int */
/** @var int|NULL */
private $limit;
@@ -118,7 +118,7 @@ class DataSource implements IDataSource
/**
* Limits number of rows.
* @param int limit
* @param int|NULL limit
* @param int offset
* @return self
*/
@@ -168,7 +168,7 @@ class DataSource implements IDataSource
/**
* Generates, executes SQL query and fetches the single row.
* @return Row|FALSE array on success, FALSE if no next record
* @return Row|FALSE
*/
public function fetch()
{

View File

@@ -15,6 +15,9 @@ class DateTime extends \DateTime
{
use Strict;
/**
* @param string|int
*/
public function __construct($time = 'now', \DateTimeZone $timezone = NULL)
{
if (is_numeric($time)) {

View File

@@ -28,16 +28,16 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
const ERROR_EXCEPTION_THROWN = -836;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
private $autoFree = TRUE;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $transaction;
/** @var bool */
@@ -215,7 +215,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the connection resource.
* @return resource
* @return resource|NULL
*/
public function getResource()
{
@@ -260,24 +260,40 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "'" . str_replace("'", "''", $value) . "'";
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
return '"' . str_replace('"', '""', $value). '"';
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -287,6 +303,10 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -329,6 +349,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -411,7 +434,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
* @return resource
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -26,10 +26,10 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
{
use Dibi\Strict;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
@@ -164,7 +164,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
* @return mixed
* @return resource|NULL
*/
public function getResource()
{
@@ -200,7 +200,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -209,12 +209,20 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "'" . str_replace("'", "''", $value) . "'";
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
@@ -222,12 +230,20 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -237,6 +253,10 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -280,6 +300,9 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -375,7 +398,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
* @return mixed
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -36,10 +36,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
const ERROR_DUPLICATE_ENTRY = 1062;
const ERROR_DATA_TRUNCATED = 1265;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
@@ -243,7 +243,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
* @return mixed
* @return resource|NULL
*/
public function getResource()
{
@@ -279,7 +279,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -291,6 +291,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
if (!is_resource($this->connection)) {
@@ -300,6 +304,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
// @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
@@ -307,12 +315,20 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -322,6 +338,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -365,6 +385,9 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -469,7 +492,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
* @return mixed
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -37,10 +37,10 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
const ERROR_DUPLICATE_ENTRY = 1062;
const ERROR_DATA_TRUNCATED = 1265;
/** @var mysqli Connection resource */
/** @var \mysqli|NULL */
private $connection;
/** @var mysqli_result Resultset resource */
/** @var \mysqli_result|NULL */
private $resultSet;
/** @var bool */
@@ -258,7 +258,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
* @return mysqli
* @return \mysqli
*/
public function getResource()
{
@@ -278,7 +278,6 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Result set driver factory.
* @param mysqli_result
* @return Dibi\ResultDriver
*/
public function createResultDriver(\mysqli_result $resource)
@@ -294,7 +293,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -303,24 +302,40 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
return '`' . str_replace('`', '``', $value) . '`';
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -330,6 +345,10 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -373,6 +392,9 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -488,7 +510,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
* @return mysqli_result
* @return \mysqli_result|NULL
*/
public function getResultResource()
{

View File

@@ -25,10 +25,10 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
use Dibi\Strict;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
@@ -189,7 +189,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the connection resource.
* @return mixed
* @return resource|NULL
*/
public function getResource()
{
@@ -225,7 +225,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -234,24 +234,40 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "'" . str_replace("'", "''", $value) . "'";
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
return '[' . str_replace(['[', ']'], ['[[', ']]'], $value) . ']';
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -261,6 +277,10 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -304,6 +324,9 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -413,7 +436,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
* @return mixed
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -29,10 +29,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
use Dibi\Strict;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
@@ -212,7 +212,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the connection resource.
* @return mixed
* @return resource|NULL
*/
public function getResource()
{
@@ -248,7 +248,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -257,12 +257,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
// @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
@@ -270,12 +278,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -285,6 +301,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -329,6 +349,9 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -427,7 +450,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
* @return mixed
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -30,7 +30,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/** @var PDO Connection resource */
private $connection;
/** @var \PDOStatement Resultset resource */
/** @var \PDOStatement|NULL Resultset resource */
private $resultSet;
/** @var int|FALSE Affected rows */
@@ -254,7 +254,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -267,6 +267,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
if ($this->driverName === 'odbc') {
@@ -277,6 +281,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
switch ($this->driverName) {
@@ -304,6 +312,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
if ($this->driverName === 'pgsql') {
@@ -314,6 +326,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -323,6 +339,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -394,6 +414,9 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -548,7 +571,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
* @return \PDOStatement
* @return \PDOStatement|NULL
*/
public function getResultResource()
{

View File

@@ -26,10 +26,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
use Dibi\Strict;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
@@ -256,7 +256,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the connection resource.
* @return mixed
* @return resource|NULL
*/
public function getResource()
{
@@ -292,7 +292,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -304,6 +304,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
if (!is_resource($this->connection)) {
@@ -313,6 +317,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
@@ -320,12 +328,20 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 'TRUE' : 'FALSE';
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -335,6 +351,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -380,6 +400,9 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -475,7 +498,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
* @return mixed
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -27,10 +27,10 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
{
use Dibi\Strict;
/** @var SQLite3 Connection resource */
/** @var SQLite3|NULL */
private $connection;
/** @var \SQLite3Result Resultset resource */
/** @var \SQLite3Result|NULL */
private $resultSet;
/** @var bool */
@@ -209,7 +209,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
* @return mixed
* @return SQLite3
*/
public function getResource()
{
@@ -245,7 +245,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -254,24 +254,40 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "X'" . bin2hex((string) $value) . "'";
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
return '[' . strtr($value, '[]', ' ') . ']';
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -281,6 +297,10 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -324,6 +344,9 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -431,7 +454,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
* @return mixed
* @return \SQLite3Result|NULL
*/
public function getResultResource()
{

View File

@@ -29,10 +29,10 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
{
use Dibi\Strict;
/** @var resource Connection resource */
/** @var resource|NULL */
private $connection;
/** @var resource Resultset resource */
/** @var resource|NULL */
private $resultSet;
/** @var bool */
@@ -188,7 +188,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
* @return mixed
* @return resource|NULL
*/
public function getResource()
{
@@ -224,7 +224,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
public function escapeText($value)
@@ -233,12 +233,20 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param string
* @return string
*/
public function escapeBinary($value)
{
return "'" . str_replace("'", "''", $value) . "'";
}
/**
* @param string
* @return string
*/
public function escapeIdentifier($value)
{
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
@@ -246,12 +254,20 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param bool
* @return string
*/
public function escapeBool($value)
{
return $value ? 1 : 0;
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDate($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -261,6 +277,10 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
}
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
public function escapeDateTime($value)
{
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
@@ -304,6 +324,9 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -405,7 +428,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
* @return mixed
* @return resource|NULL
*/
public function getResultResource()
{

View File

@@ -300,7 +300,7 @@ class Fluent implements IDataSource
/**
* Generates and executes SQL query.
* @param mixed what to return?
* @return Result|int result set object (if any)
* @return Result|int result set or number of affected rows
* @throws Exception
*/
public function execute($return = NULL)
@@ -319,7 +319,7 @@ class Fluent implements IDataSource
/**
* Generates, executes SQL query and fetches the single row.
* @return Row|FALSE array on success, FALSE if no next record
* @return Row|FALSE
*/
public function fetch()
{

View File

@@ -19,10 +19,10 @@ use Dibi\Type;
* @property-read Table $table
* @property-read string $type
* @property-read mixed $nativeType
* @property-read int $size
* @property-read bool $unsigned
* @property-read bool $nullable
* @property-read bool $autoIncrement
* @property-read int|NULL $size
* @property-read bool|NULL $unsigned
* @property-read bool|NULL $nullable
* @property-read bool|NULL $autoIncrement
* @property-read mixed $default
*/
class Column
@@ -83,7 +83,7 @@ class Column
/**
* @return string
* @return string|NULL
*/
public function getTableName()
{
@@ -101,7 +101,7 @@ class Column
/**
* @return mixed
* @return string
*/
public function getNativeType()
{
@@ -110,7 +110,7 @@ class Column
/**
* @return int
* @return int|NULL
*/
public function getSize()
{
@@ -119,7 +119,7 @@ class Column
/**
* @return bool
* @return bool|NULL
*/
public function isUnsigned()
{
@@ -128,7 +128,7 @@ class Column
/**
* @return bool
* @return bool|NULL
*/
public function isNullable()
{
@@ -137,7 +137,7 @@ class Column
/**
* @return bool
* @return bool|NULL
*/
public function isAutoIncrement()
{

View File

@@ -184,7 +184,7 @@ class Result implements IDataSource
/**
* Fetches the row at current position, process optional type conversion.
* and moves the internal cursor to the next position
* @return Row|FALSE array on success, FALSE if no next record
* @return Row|FALSE
*/
final public function fetch()
{
@@ -558,9 +558,9 @@ class Result implements IDataSource
/**
* Sets data format.
* @param string type (use constant Type::*)
* @param string format
* Sets date format.
* @param string
* @param string|NULL format
* @return self
*/
final public function setFormat($type, $format)
@@ -572,7 +572,7 @@ class Result implements IDataSource
/**
* Returns data format.
* @return string
* @return string|NULL
*/
final public function getFormat($type)
{

View File

@@ -27,7 +27,7 @@ class ResultIterator implements \Iterator, \Countable
/** @var Result */
private $result;
/** @var int */
/** @var mixed */
private $row;
/** @var int */

View File

@@ -105,7 +105,7 @@ trait Strict
/**
* @param string method name
* @param callabke
* @param callable
* @return mixed
*/
public static function extensionMethod($name, $callback = NULL)

View File

@@ -167,7 +167,7 @@ class dibi
/**
* Generates and executes SQL query - Monostate for Dibi\Connection::query().
* @param array|mixed one or more arguments
* @return Dibi\Result|int result set object (if any)
* @return Dibi\Result|int result set or number of affected rows
* @throws Dibi\Exception
*/
public static function query($args)
@@ -180,7 +180,7 @@ class dibi
/**
* Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().
* @param string SQL statement.
* @return Dibi\Result|int result set object (if any)
* @return Dibi\Result|int result set or number of affected rows
*/
public static function nativeQuery($sql)
{
@@ -241,7 +241,7 @@ class dibi
/**
* Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().
* @param array|mixed one or more arguments
* @return string
* @return mixed
* @throws Dibi\Exception
*/
public static function fetchSingle($args)
@@ -382,7 +382,7 @@ class dibi
/**
* @param string column name
* @param mixed column name
* @return Dibi\Fluent
*/
public static function select($args)

View File

@@ -97,19 +97,39 @@ interface Driver
/**
* Encodes data for use in a SQL statement.
* @param mixed value
* @param string value
* @return string encoded value
*/
function escapeText($value);
/**
* @param string
* @return string
*/
function escapeBinary($value);
/**
* @param string
* @return string
*/
function escapeIdentifier($value);
/**
* @param bool
* @return string
*/
function escapeBool($value);
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
function escapeDate($value);
/**
* @param \DateTime|\DateTimeInterface|string|int
* @return string
*/
function escapeDateTime($value);
/**
@@ -122,6 +142,9 @@ interface Driver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
* @param int|NULL
* @param int|NULL
* @return void
*/
function applyLimit(&$sql, $limit, $offset);