PHP Класс Database, testswarm

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

Защищенные свойства (Protected)

Свойство Тип Описание
$conn
$dbname
$delimiter
$host
$ignoreErrors
$isOpen
$password
$username

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

Метод Описание
addIdentifierQuotes ( $s )
batchQueryFromFile ( $fullSource ) : boolean Roughly parse a .sql file and execute it in small batches
close ( ) : boolean
fieldExists ( $table, $fieldName ) : bool: Determines whether a field exists in a table.
fieldInfo ( $table, $fieldName ) : boolean | object:
freeResult ( $res )
getAffectedRows ( ) : integer
getDBname ( ) : string:
getInsertId ( ) : integer
getNumRows ( $res ) : integer
getOne ( $sql ) : mixed | false
getQueryLog ( )
getRow ( $sql ) : obj | false
getRows ( $sql ) : array
ignoreErrors ( $setting )
lastErrMsg ( )
lastErrNo ( )
newFromContext ( TestSwarmContext $context ) Creates a Database object, opens the connection and returns the instance.
open ( )
query ( $sql ) : resource | false Queries other than SELECT, such as DELETE, UPDATE and INSERT.
strEncode ( $str )
tableExists ( $table ) : boolean

Защищенные методы

Метод Описание
checkEnvironment ( )
closeConn ( ) : boolean
doQuery ( $sql ) : MySQL Execute actual queries. Within this class, this function should be used to do queries, not the wrapper function query(). The logger will log the caller of the caller of this function. So there should be one function in between this and outside this class.
fetchObject ( $res )
getContext ( )
logQuery ( $sql, $queryResponse, $microtimeStart ) : boolean

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

Метод Описание
__construct ( )

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

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

public addIdentifierQuotes ( $s )

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

Roughly parse a .sql file and execute it in small batches
public batchQueryFromFile ( $fullSource ) : boolean
$fullSource string: Full source of .sql file There should be no more than 1 statement (ending in ;) on a single line.
Результат boolean

checkEnvironment() защищенный метод

protected checkEnvironment ( )

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

public close ( ) : boolean
Результат boolean

closeConn() защищенный метод

protected closeConn ( ) : boolean
Результат boolean

doQuery() защищенный метод

Execute actual queries. Within this class, this function should be used to do queries, not the wrapper function query(). The logger will log the caller of the caller of this function. So there should be one function in between this and outside this class.
protected doQuery ( $sql ) : MySQL
Результат MySQL resource|false

fetchObject() защищенный метод

protected fetchObject ( $res )

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

Determines whether a field exists in a table.
public fieldExists ( $table, $fieldName ) : bool:
$table string
$fieldName string
Результат bool:

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

public fieldInfo ( $table, $fieldName ) : boolean | object:
$table string
$fieldName string
Результат boolean | object:

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

public freeResult ( $res )

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

public getAffectedRows ( ) : integer
Результат integer

getContext() закрытый защищенный метод

final protected getContext ( )

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

public getDBname ( ) : string:
Результат string:

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

public getInsertId ( ) : integer
Результат integer

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

public getNumRows ( $res ) : integer
Результат integer

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

public getOne ( $sql ) : mixed | false
Результат mixed | false

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

public getQueryLog ( )

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

public getRow ( $sql ) : obj | false
Результат obj | false

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

public getRows ( $sql ) : array
Результат array of objects|false

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

public ignoreErrors ( $setting )

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

public lastErrMsg ( )

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

public lastErrNo ( )

logQuery() защищенный метод

protected logQuery ( $sql, $queryResponse, $microtimeStart ) : boolean
Результат boolean Whether or not log info was actually generated and saved, false by default for performance reasons, can be enabled in the configuration file.

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

Creates a Database object, opens the connection and returns the instance.
public static newFromContext ( TestSwarmContext $context )
$context TestSwarmContext

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

public open ( )

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

SELECT queries should use getOne, getRow or getRows.
public query ( $sql ) : resource | false
Результат resource | false

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

public strEncode ( $str )

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

public tableExists ( $table ) : boolean
Результат boolean

Описание свойств

$conn защищенное свойство

protected $conn

$dbname защищенное свойство

protected $dbname

$delimiter защищенное свойство

protected $delimiter

$host защищенное свойство

protected $host

$ignoreErrors защищенное свойство

protected $ignoreErrors

$isOpen защищенное свойство

protected $isOpen

$password защищенное свойство

protected $password

$username защищенное свойство

protected $username