PHP Класс Pop\Db\Record

Автор: Nick Sagona, III ([email protected])
Наследование: implements ArrayAccess
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$db array Database connection(s)
$rows array Rows of multiple return results from a database query in an ArrayObject format.

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

Свойство Тип Описание
$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

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

Метод Описание
__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.

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

Метод Описание
camelCaseToUnderscore ( string $string ) : string Method to convert a camelCase string to an under_score string
setResults ( array $result ) : void Set the query results.

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

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

Instantiate the database record object.
public __construct ( array $columns = null, Db $db = null ) : Record
$columns array
$db Db
Результат Record

__get() публичный Метод

Get method to return the value of columns[$name].
public __get ( string $name ) : mixed
$name string
Результат mixed

__isset() публичный Метод

Return the isset value of columns[$name].
public __isset ( string $name ) : boolean
$name string
Результат boolean

__set() публичный Метод

Set method to set the property to the value of columns[$name].
public __set ( string $name, mixed $value ) : void
$name string
$value mixed
Результат void

__unset() публичный Метод

Unset columns[$name].
public __unset ( string $name ) : void
$name string
Результат void

camelCaseToUnderscore() защищенный Метод

Method to convert a camelCase string to an under_score string
protected camelCaseToUnderscore ( string $string ) : string
$string string
Результат string

count() публичный Метод

Method to return the current number of records.
public count ( ) : integer
Результат integer

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

Delete the database record.
public delete ( array $columns = null ) : void
$columns array
Результат void

escape() публичный Метод

Return the escaped string value.
public escape ( string $value ) : string
$value string
Результат string

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

Execute a custom prepared SQL query.
public static execute ( string $sql, array $params = null ) : Record
$sql string
$params array
Результат Record

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

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
Результат Record

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

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
Результат Record

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

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
Результат Record

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

Get total count of records
public static getCount ( array $columns = null ) : mixed
$columns array
Результат mixed

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

Get DB connection
public static getDb ( ) : Db
Результат Db

getFullTableName() публичный Метод

Get the full table name, with the prefix
public getFullTableName ( ) : string
Результат string

getId() публичный Метод

Get the table primary ID
public getId ( ) : mixed
Результат mixed

getPrefix() публичный Метод

Get the table prefix
public getPrefix ( ) : string
Результат string

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

Get the SQL object.
public static getSql ( ) : Sql
Результат Sql

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

Get table info anf return as an array.
public static getTableInfo ( ) : array
Результат array

getTableName() публичный Метод

Get the abbreviated table name, without the prefix
public getTableName ( ) : string
Результат string

getValues() публичный Метод

Get all the table column values at once as an associative array.
public getValues ( ) : array
Результат array

isAuto() публичный Метод

Get if the table is an autoincrement table
public isAuto ( ) : boolean
Результат boolean

isPrepared() публичный Метод

Get if the record interface is prepared or not
public isPrepared ( ) : boolean
Результат boolean

lastId() публичный Метод

Return the auto-increment ID of the last query.
public lastId ( ) : integer
Результат integer

numFields() публичный Метод

Return the number of fields in the result.
public numFields ( ) : integer
Результат integer

numRows() публичный Метод

Return the number of rows in the result.
public numRows ( ) : integer
Результат integer

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

Execute a custom SQL query.
public static query ( string $sql ) : Record
$sql string
Результат Record

save() публичный Метод

Save the database record.
public save ( integer $type = Record::INSERT ) : void
$type integer
Результат void

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

Set DB connection
public static setDb ( Db $db, boolean $isDefault = false ) : void
$db Db
$isDefault boolean
Результат void

setResults() защищенный Метод

Set the query results.
protected setResults ( array $result ) : void
$result array
Результат void

setValues() публичный Метод

Set all the table column values at once.
public setValues ( array $columns = null ) : Record
$columns array
Результат Record

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

Update (save) the existing database record.
public update ( ) : void
Результат void

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

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

Property that determines whether or not the primary ID is auto-increment or not
protected bool $auto
Результат boolean

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

Column names of the database table
protected array $columns
Результат array

$db публичное статическое свойство

Database connection(s)
public static array $db
Результат array

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

Record interface
protected AbstractRecord,Pop\Db\Record $interface
Результат Pop\Db\Record\AbstractRecord

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

Table prefix
protected string $prefix
Результат string

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

Primary ID column name of the database table
protected string|array $primaryId
Результат string | array

$rows публичное свойство

Rows of multiple return results from a database query in an ArrayObject format.
public array $rows
Результат array

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

Table name of the database table
protected string $tableName
Результат string

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

Flag on whether or not to use prepared statements
protected bool $usePrepared
Результат boolean