PHP Класс App\services\Database

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( array $config = null ) Construct with a config array.
__destruct ( )
delete ( $condition = null, $table = null )
fetchArray ( $sql )
getNumRows ( $key, $value, $table = null )
getRecordNum ( $table = null )
has ( $key, $value, $table = null )
hasTable ( $tableName )
insert ( $data, $table = null )
prepareConnection ( array $config = null ) : mysqli Try to connect to the database with given config.
query ( $sql )
select ( string $key, string $value, array $condition = null, string $table = null, boolean $dont_fetch_array = false ) : array | resources Select records from table
table ( $tableName, $no_prefix = false )
update ( $key, $value, $condition = null, $table = null )

Приватные методы

Метод Описание
where ( array $condition ) : string Generate where statement

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

__construct() публичный метод

Construct with a config array.
public __construct ( array $config = null )
$config array

__destruct() публичный метод

public __destruct ( )

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

public delete ( $condition = null, $table = null )

fetchArray() публичный метод

public fetchArray ( $sql )

getNumRows() публичный метод

public getNumRows ( $key, $value, $table = null )

getRecordNum() публичный метод

public getRecordNum ( $table = null )

has() публичный метод

public has ( $key, $value, $table = null )

hasTable() публичный метод

public hasTable ( $tableName )

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

public insert ( $data, $table = null )

prepareConnection() публичный статический метод

Try to connect to the database with given config.
public static prepareConnection ( array $config = null ) : mysqli
$config array
Результат mysqli

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

public query ( $sql )

select() публичный метод

Select records from table
public select ( string $key, string $value, array $condition = null, string $table = null, boolean $dont_fetch_array = false ) : array | resources
$key string
$value string
$condition array See function `where`
$table string Which table to operate
$dont_fetch_array boolean Return resources if true
Результат array | resources

table() публичный метод

public table ( $tableName, $no_prefix = false )

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

public update ( $key, $value, $condition = null, $table = null )