PHP Интерфейс ManaPHP\DbInterface

Показать файл Открыть проект

Открытые методы

Метод Описание
affectedRows ( ) : integer Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system
begin ( ) : void Starts a transaction in the connection
commit ( ) : void Commits the active transaction in the connection
delete ( string $table, string | array $conditions, array $bind = [] ) : integer Deletes data from a table using custom SQL syntax
escapeIdentifier ( string | array $identifier ) : string Escapes a column/table/schema name
execute ( string $sql, array $bind = [] ) : integer Sends SQL statements to the database server returning the success state.
fetchAll ( string $sql, array $bind = [], integer $fetchMode = PDO::FETCH_ASSOC ) : array Dumps the complete result of a query into an array
fetchOne ( string $sql, array $bind = [], integer $fetchMode = PDO::FETCH_ASSOC ) : array | false Returns the first row in a SQL query result
getBind ( ) : array Active SQL statement in the object
getEmulatedSQL ( integer $preservedStrLength ) : string Active SQL statement in the object with replace the bind with value
getMetadata ( $source ) : array
getSQL ( ) : string Active SQL statement in the object
insert ( string $table, array $columnValues ) : void Inserts data into a table using custom SQL syntax
isUnderTransaction ( ) : boolean Checks whether the connection is under a transaction
lastInsertId ( ) : integer Returns insert id for the auto_increment column inserted in the last SQL statement
limit ( string $sql, integer $number, integer $offset = null ) : string Appends a LIMIT clause to $sql argument
query ( string $sql, array $bind = [], integer $fetchMode = PDO::FETCH_ASSOC ) : PDOStatement Sends SQL statements to the database server returning the success state.
rollback ( ) : void Rollbacks the active transaction in the connection
truncateTable ( string $source ) : static
update ( string $table, array $columnValues, string | array $conditions, array $bind = [] ) : integer Updates data on a table using custom SQL syntax

Описание методов

affectedRows() публичный Метод

Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system
public affectedRows ( ) : integer
Результат integer

begin() публичный Метод

Starts a transaction in the connection
public begin ( ) : void
Результат void

commit() публичный Метод

Commits the active transaction in the connection
public commit ( ) : void
Результат void

delete() публичный Метод

$db->delete('_student','id=1'); $db->delete('_student',['id'=>1]); $db->delete('_student',['id'=>1]); $db->delete('_student','id=:id',['id'=>1]);
public delete ( string $table, string | array $conditions, array $bind = [] ) : integer
$table string
$conditions string | array
$bind array
Результат integer

escapeIdentifier() публичный Метод

Escapes a column/table/schema name
public escapeIdentifier ( string | array $identifier ) : string
$identifier string | array
Результат string

execute() публичный Метод

Use this method only when the SQL statement sent to the server don't return any row
public execute ( string $sql, array $bind = [] ) : integer
$sql string
$bind array
Результат integer

fetchAll() публичный Метод

$db->fetchAll('SELECT * FROM city'); $db->fetchAll('SELECT * FROM city WHERE city_id <:city_id',['city_id'=>5]);
public fetchAll ( string $sql, array $bind = [], integer $fetchMode = PDO::FETCH_ASSOC ) : array
$sql string
$bind array
$fetchMode integer
Результат array

fetchOne() публичный Метод

$db->fetchOne('SELECT * FROM city'); $db->fetchOne('SELECT * FROM city WHERE city_id =:city_id',['city_id'=>5]);
public fetchOne ( string $sql, array $bind = [], integer $fetchMode = PDO::FETCH_ASSOC ) : array | false
$sql string
$bind array
$fetchMode integer
Результат array | false

getBind() публичный Метод

Active SQL statement in the object
public getBind ( ) : array
Результат array

getEmulatedSQL() публичный Метод

Active SQL statement in the object with replace the bind with value
public getEmulatedSQL ( integer $preservedStrLength ) : string
$preservedStrLength integer
Результат string

getMetadata() публичный Метод

public getMetadata ( $source ) : array
Результат array

getSQL() публичный Метод

Active SQL statement in the object
public getSQL ( ) : string
Результат string

insert() публичный Метод

$db->insert('_student',['age'=>30,'name'=>'Mark']); $db->insert('_student',[null,30,'Mark']);
public insert ( string $table, array $columnValues ) : void
$table string
$columnValues array
Результат void

isUnderTransaction() публичный Метод

$connection->begin(); var_dump($connection->isUnderTransaction()); //true
public isUnderTransaction ( ) : boolean
Результат boolean

lastInsertId() публичный Метод

Returns insert id for the auto_increment column inserted in the last SQL statement
public lastInsertId ( ) : integer
Результат integer

limit() публичный Метод

$db->limit('',10); //LIMIT 10 $db->limit('',10,100); //LIMIT 10 OFFSET 100
public limit ( string $sql, integer $number, integer $offset = null ) : string
$sql string
$number integer
$offset integer
Результат string

query() публичный Метод

Use this method only when the SQL statement sent to the server return rows
public query ( string $sql, array $bind = [], integer $fetchMode = PDO::FETCH_ASSOC ) : PDOStatement
$sql string
$bind array
$fetchMode integer
Результат PDOStatement

rollback() публичный Метод

Rollbacks the active transaction in the connection
public rollback ( ) : void
Результат void

truncateTable() публичный Метод

public truncateTable ( string $source ) : static
$source string
Результат static

update() публичный Метод

$db->update('_student',['name'=>'mark'],'id=2'); $db->update('_student',['name'=>'mark'],['id'=>2]); $db->update('_student',['name'=>'mark'],'id=:id',['id'=>2]);
public update ( string $table, array $columnValues, string | array $conditions, array $bind = [] ) : integer
$table string
$columnValues array
$conditions string | array
$bind array
Результат integer