PHP Class ptejada\uFlex\DB_Table

Author: Pablo Tejada ([email protected])
Show file Open project: ptejada/uflex

Public Properties

Property Type Description
$log - Log errors and report

Public Methods

Method Description
__construct ( ptejada\uFlex\DB $db, string $table ) Initializes a database table object
getLastInsertedID ( ) : integer Get the ID of the last inserted record
getRow ( array $arguments ) : boolean | ptejada\uFlex\Collection Get a single row from the table depending on arguments
getStatement ( string $sql, boolean | mixed[] $args = false ) : boolean | PDOStatement Get a PDO statement
isUnique ( string $field, string | integer $val, boolean | string $customError = false ) : boolean Test field value in database Check for the uniqueness of a value in a specified field/column.
query ( $sql, boolean $arguments = false ) : boolean | PDOStatement Query the table
runQuery ( string $sql, array | boolean $arguments = false ) : boolean Executes SQL query and checks for success

Private Methods

Method Description
buildQuery ( string $sql, array $arguments = null ) : string Builds a query string with the passed arguments

Method Details

__construct() public method

Initializes a database table object
public __construct ( ptejada\uFlex\DB $db, string $table )
$db ptejada\uFlex\DB
$table string

getLastInsertedID() public method

Get the ID of the last inserted record
public getLastInsertedID ( ) : integer
return integer

getRow() public method

Get a single row from the table depending on arguments
public getRow ( array $arguments ) : boolean | ptejada\uFlex\Collection
$arguments array - field and value pair set to look up user for
return boolean | ptejada\uFlex\Collection

getStatement() public method

Get a PDO statement
public getStatement ( string $sql, boolean | mixed[] $args = false ) : boolean | PDOStatement
$sql string SQL query string
$args boolean | mixed[] argument to execute the statement with
return boolean | PDOStatement

isUnique() public method

For example could be use to check for the uniqueness of a Username or email prior to registration
public isUnique ( string $field, string | integer $val, boolean | string $customError = false ) : boolean
$field string The name of the field
$val string | integer The value for the field to check
$customError boolean | string Error string to log if field value is not unique
return boolean

query() public method

Query the table
public query ( $sql, boolean $arguments = false ) : boolean | PDOStatement
$sql
$arguments boolean
return boolean | PDOStatement

runQuery() public method

Executes SQL query and checks for success
public runQuery ( string $sql, array | boolean $arguments = false ) : boolean
$sql string - SQL query string
$arguments array | boolean - Array of arguments to execute $sql with
return boolean

Property Details

$log public property

- Log errors and report
public $log