PHP Class Pop\Db\Record

Author: Nick Sagona, III ([email protected])
Inheritance: implements ArrayAccess
Afficher le fichier Open project: nicksagona/PopPHP Class Usage Examples

Méthodes publiques

Свойство Type Description
$db array Database connection(s)
$rows array Rows of multiple return results from a database query in an ArrayObject format.

Protected Properties

Свойство Type Description
$auto boolean Property that determines whether or not the primary ID is auto-increment or not
$columns array Column names of the database table
$interface Pop\Db\Record\AbstractRecord Record interface
$prefix string Table prefix
$primaryId string | array Primary ID column name of the database table
$tableName string Table name of the database table
$usePrepared boolean Flag on whether or not to use prepared statements

Méthodes publiques

Méthode Description
__construct ( array $columns = null, Db $db = null ) : Record Constructor
__get ( string $name ) : mixed Get method to return the value of columns[$name].
__isset ( string $name ) : boolean Return the isset value of columns[$name].
__set ( string $name, mixed $value ) : void Set method to set the property to the value of columns[$name].
__unset ( string $name ) : void Unset columns[$name].
count ( ) : integer Method to return the current number of records.
delete ( array $columns = null ) : void Delete the database record.
escape ( string $value ) : string Return the escaped string value.
execute ( string $sql, array $params = null ) : Record Execute a custom prepared SQL query.
findAll ( string $order = null, array $columns = null, integer $limit = null, integer $offset = null ) : Record Find all of the database rows by the column passed through the method argument.
findBy ( array $columns, string $order = null, integer $limit = null, integer $offset = null ) : Record Find a database row by the column passed through the method argument.
findById ( mixed $id, integer $limit = null, integer $offset = null ) : Record Find a database row by the primary ID passed through the method argument.
getCount ( array $columns = null ) : mixed Get total count of records
getDb ( ) : Db Get DB connection
getFullTableName ( ) : string Get the full table name, with the prefix
getId ( ) : mixed Get the table primary ID
getPrefix ( ) : string Get the table prefix
getSql ( ) : Sql Get the SQL object.
getTableInfo ( ) : array Get table info anf return as an array.
getTableName ( ) : string Get the abbreviated table name, without the prefix
getValues ( ) : array Get all the table column values at once as an associative array.
isAuto ( ) : boolean Get if the table is an autoincrement table
isPrepared ( ) : boolean Get if the record interface is prepared or not
lastId ( ) : integer Return the auto-increment ID of the last query.
numFields ( ) : integer Return the number of fields in the result.
numRows ( ) : integer Return the number of rows in the result.
query ( string $sql ) : Record Execute a custom SQL query.
save ( integer $type = Record::INSERT ) : void Save the database record.
setDb ( Db $db, boolean $isDefault = false ) : void Set DB connection
setValues ( array $columns = null ) : Record Set all the table column values at once.
update ( ) : void Update (save) the existing database record.

Méthodes protégées

Méthode Description
camelCaseToUnderscore ( string $string ) : string Method to convert a camelCase string to an under_score string
setResults ( array $result ) : void Set the query results.

Method Details

__construct() public méthode

Instantiate the database record object.
public __construct ( array $columns = null, Db $db = null ) : Record
$columns array
$db Db
Résultat Record

__get() public méthode

Get method to return the value of columns[$name].
public __get ( string $name ) : mixed
$name string
Résultat mixed

__isset() public méthode

Return the isset value of columns[$name].
public __isset ( string $name ) : boolean
$name string
Résultat boolean

__set() public méthode

Set method to set the property to the value of columns[$name].
public __set ( string $name, mixed $value ) : void
$name string
$value mixed
Résultat void

__unset() public méthode

Unset columns[$name].
public __unset ( string $name ) : void
$name string
Résultat void

camelCaseToUnderscore() protected méthode

Method to convert a camelCase string to an under_score string
protected camelCaseToUnderscore ( string $string ) : string
$string string
Résultat string

count() public méthode

Method to return the current number of records.
public count ( ) : integer
Résultat integer

delete() public méthode

Delete the database record.
public delete ( array $columns = null ) : void
$columns array
Résultat void

escape() public méthode

Return the escaped string value.
public escape ( string $value ) : string
$value string
Résultat string

execute() public static méthode

Execute a custom prepared SQL query.
public static execute ( string $sql, array $params = null ) : Record
$sql string
$params array
Résultat Record

findAll() public static méthode

Find all of the database rows by the column passed through the method argument.
public static findAll ( string $order = null, array $columns = null, integer $limit = null, integer $offset = null ) : Record
$order string
$columns array
$limit integer
$offset integer
Résultat Record

findBy() public static méthode

Find a database row by the column passed through the method argument.
public static findBy ( array $columns, string $order = null, integer $limit = null, integer $offset = null ) : Record
$columns array
$order string
$limit integer
$offset integer
Résultat Record

findById() public static méthode

Find a database row by the primary ID passed through the method argument.
public static findById ( mixed $id, integer $limit = null, integer $offset = null ) : Record
$id mixed
$limit integer
$offset integer
Résultat Record

getCount() public static méthode

Get total count of records
public static getCount ( array $columns = null ) : mixed
$columns array
Résultat mixed

getDb() public static méthode

Get DB connection
public static getDb ( ) : Db
Résultat Db

getFullTableName() public méthode

Get the full table name, with the prefix
public getFullTableName ( ) : string
Résultat string

getId() public méthode

Get the table primary ID
public getId ( ) : mixed
Résultat mixed

getPrefix() public méthode

Get the table prefix
public getPrefix ( ) : string
Résultat string

getSql() public static méthode

Get the SQL object.
public static getSql ( ) : Sql
Résultat Sql

getTableInfo() public static méthode

Get table info anf return as an array.
public static getTableInfo ( ) : array
Résultat array

getTableName() public méthode

Get the abbreviated table name, without the prefix
public getTableName ( ) : string
Résultat string

getValues() public méthode

Get all the table column values at once as an associative array.
public getValues ( ) : array
Résultat array

isAuto() public méthode

Get if the table is an autoincrement table
public isAuto ( ) : boolean
Résultat boolean

isPrepared() public méthode

Get if the record interface is prepared or not
public isPrepared ( ) : boolean
Résultat boolean

lastId() public méthode

Return the auto-increment ID of the last query.
public lastId ( ) : integer
Résultat integer

numFields() public méthode

Return the number of fields in the result.
public numFields ( ) : integer
Résultat integer

numRows() public méthode

Return the number of rows in the result.
public numRows ( ) : integer
Résultat integer

query() public static méthode

Execute a custom SQL query.
public static query ( string $sql ) : Record
$sql string
Résultat Record

save() public méthode

Save the database record.
public save ( integer $type = Record::INSERT ) : void
$type integer
Résultat void

setDb() public static méthode

Set DB connection
public static setDb ( Db $db, boolean $isDefault = false ) : void
$db Db
$isDefault boolean
Résultat void

setResults() protected méthode

Set the query results.
protected setResults ( array $result ) : void
$result array
Résultat void

setValues() public méthode

Set all the table column values at once.
public setValues ( array $columns = null ) : Record
$columns array
Résultat Record

update() public méthode

Update (save) the existing database record.
public update ( ) : void
Résultat void

Property Details

$auto protected_oe property

Property that determines whether or not the primary ID is auto-increment or not
protected bool $auto
Résultat boolean

$columns protected_oe property

Column names of the database table
protected array $columns
Résultat array

$db public_oe static_oe property

Database connection(s)
public static array $db
Résultat array

$interface protected_oe property

Record interface
protected AbstractRecord,Pop\Db\Record $interface
Résultat Pop\Db\Record\AbstractRecord

$prefix protected_oe property

Table prefix
protected string $prefix
Résultat string

$primaryId protected_oe property

Primary ID column name of the database table
protected string|array $primaryId
Résultat string | array

$rows public_oe property

Rows of multiple return results from a database query in an ArrayObject format.
public array $rows
Résultat array

$tableName protected_oe property

Table name of the database table
protected string $tableName
Résultat string

$usePrepared protected_oe property

Flag on whether or not to use prepared statements
protected bool $usePrepared
Résultat boolean