PHP Class Database, testswarm

Author: Adam Clarke
Datei anzeigen Open project: jquery/testswarm Class Usage Examples

Protected Properties

Property Type Description
$conn
$dbname
$delimiter
$host
$ignoreErrors
$isOpen
$password
$username

Public Methods

Method Description
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

Protected Methods

Method Description
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

Private Methods

Method Description
__construct ( )

Method Details

addIdentifierQuotes() public method

public addIdentifierQuotes ( $s )

batchQueryFromFile() public method

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.
return boolean

checkEnvironment() protected method

protected checkEnvironment ( )

close() public method

public close ( ) : boolean
return boolean

closeConn() protected method

protected closeConn ( ) : boolean
return boolean

doQuery() protected method

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
return MySQL resource|false

fetchObject() protected method

protected fetchObject ( $res )

fieldExists() public method

Determines whether a field exists in a table.
public fieldExists ( $table, $fieldName ) : bool:
$table string
$fieldName string
return bool:

fieldInfo() public method

public fieldInfo ( $table, $fieldName ) : boolean | object:
$table string
$fieldName string
return boolean | object:

freeResult() public method

public freeResult ( $res )

getAffectedRows() public method

public getAffectedRows ( ) : integer
return integer

getContext() final protected method

final protected getContext ( )

getDBname() public method

public getDBname ( ) : string:
return string:

getInsertId() public method

public getInsertId ( ) : integer
return integer

getNumRows() public method

public getNumRows ( $res ) : integer
return integer

getOne() public method

public getOne ( $sql ) : mixed | false
return mixed | false

getQueryLog() public method

public getQueryLog ( )

getRow() public method

public getRow ( $sql ) : obj | false
return obj | false

getRows() public method

public getRows ( $sql ) : array
return array of objects|false

ignoreErrors() public method

public ignoreErrors ( $setting )

lastErrMsg() public method

public lastErrMsg ( )

lastErrNo() public method

public lastErrNo ( )

logQuery() protected method

protected logQuery ( $sql, $queryResponse, $microtimeStart ) : boolean
return 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() public static method

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

open() public method

public open ( )

query() public method

SELECT queries should use getOne, getRow or getRows.
public query ( $sql ) : resource | false
return resource | false

strEncode() public method

public strEncode ( $str )

tableExists() public method

public tableExists ( $table ) : boolean
return boolean

Property Details

$conn protected_oe property

protected $conn

$dbname protected_oe property

protected $dbname

$delimiter protected_oe property

protected $delimiter

$host protected_oe property

protected $host

$ignoreErrors protected_oe property

protected $ignoreErrors

$isOpen protected_oe property

protected $isOpen

$password protected_oe property

protected $password

$username protected_oe property

protected $username