PHP Класс Habari\InfoRecords

Base class for managing metadata about various Habari objects
Наследование: implements habari\URLProperties
Показать файл Открыть проект

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

Свойство Тип Описание
$__inforecord_array the info array
$_dirty set to true if any values here have been changed but not saved
$_key_name name of the primary key in the info record table
$_key_value value of the primary key - the master record
$_loaded set to true only when the inforecords have been loaded
$_table_name table which contains the info records
$url_args

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

Метод Описание
__construct ( string $table_name, string $key_name, mixed $key_value = null ) Takes three parameters. The table of the options table, the name of the master key and the record_id for which options are managed.
__get ( string $name ) : mixed Fetch info record value.
__isset ( string $name ) : boolean Test for the existence of specified info value
__set ( string $name, mixed $value ) Update the info record.
__unset ( string $name ) : boolean Remove an info option; immediately unsets from the storage AND removes from database. Use with caution.
commit ( mixed $metadata_key = null ) : boolean Commit all of the changed info options to the database.
count ( ) : integer Get the number of info records
delete_all ( ) : boolean Remove all info options. Primarily used when deleting the parent object.
getArrayCopy ( )
get_url_args ( ) : array Returns a set of properties used by URL::get to create URLs
is_key_set ( ) : boolean Test if the master record value has been set (and thus, safe to set info records).
set_key ( mixed $metadata_key ) function set_key For use in cases where the master record key is not known at the time of object instantiation (ie: a new post)

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

Метод Описание
_load ( ) Populate the internal hashmap with the values from the DB.

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

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

posts take a slug as a record_id, comments take a comment_id and users take a user_id (user_name) IMPORTANT: if $primary_key_value is not set in the constructor, set_key MUST be called before inforecords can be set. Or bad things (think swarms of locusts o'er the land) will happen
public __construct ( string $table_name, string $key_name, mixed $key_value = null )
$table_name string name of the table to insert info (use the DB::o()->table_name syntax)
$key_name string name of the primary key (for example "post_id")
$key_value mixed (optional) the master record key value (for example, info for post_id = 1 managed by setting this param to 1). Use set_key method if not set here.

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

Fetch info record value.
public __get ( string $name ) : mixed
$name string Name of the key to get
Результат mixed Stored value for specified key

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

Test for the existence of specified info value
public __isset ( string $name ) : boolean
$name string Name of the option to set
Результат boolean true if the info option exists, false in all other cases

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

The value will not be stored in the database until calling $this->commit();
public __set ( string $name, mixed $value )
$name string Name of the key to set
$value mixed Value to set

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

Remove an info option; immediately unsets from the storage AND removes from database. Use with caution.
public __unset ( string $name ) : boolean
$name string Name of the option to unset
Результат boolean true if the option is successfully unset, false otherwise

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

Populate the internal hashmap with the values from the DB.
protected _load ( )

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

If this function is not called, then the options will not be written.
public commit ( mixed $metadata_key = null ) : boolean
$metadata_key mixed (optional) Key to use when writing info data.
Результат boolean True if the commit succeeded.

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

Get the number of info records
public count ( ) : integer
Результат integer Number of info records here

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

I.E. when deleting a user, the delete method would call this.
public delete_all ( ) : boolean
Результат boolean true if the options were successfully unset, false otherwise

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

public getArrayCopy ( )

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

Returns a set of properties used by URL::get to create URLs
public get_url_args ( ) : array
Результат array Properties of this post used to build a URL

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

Test if the master record value has been set (and thus, safe to set info records).
public is_key_set ( ) : boolean
Результат boolean true if master record value has been set already, false otherwise

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

function set_key For use in cases where the master record key is not known at the time of object instantiation (ie: a new post)
public set_key ( mixed $metadata_key )
$metadata_key mixed the id of the master record (could be int or string, most likely int)

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

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

the info array
protected $__inforecord_array

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

set to true if any values here have been changed but not saved
protected $_dirty

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

name of the primary key in the info record table
protected $_key_name

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

value of the primary key - the master record
protected $_key_value

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

set to true only when the inforecords have been loaded
protected $_loaded

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

table which contains the info records
protected $_table_name

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

protected $url_args