PHP Class WordPress\ORM\BaseModel

Author: Brandon Wamboldt ([email protected])
Inheritance: implements WordPress\ORM\ModelInterface
Afficher le fichier Open project: brandonwamboldt/wp-orm Class Usage Examples

Méthodes publiques

Méthode Description
__call ( string $function, array $arguments ) : mixed Magically handle getters and setters.
__construct ( array $properties = [] ) Constructor.
all ( ) : array Return EVERY instance of this model from the database, with NO filtering.
create ( $properties ) : self Create a new model from the given data.
delete ( ) : boolean Delete the model from the database. Returns true if it was successful or false if it was not.
find_one ( integer $id ) : false | self Find a specific model by it's unique ID.
find_one_by ( string $property, string $value ) : false | self Find a specific model by a given property value.
flatten_props ( array $props ) : array Convert complex objects to strings to insert into the database.
get_primary_key ( ) : string Get the column used as the primary key, defaults to 'id'.
get_table_prefix ( ) : string Return configured table prefix.
primary_key ( ) : integer Return the value of the primary key.
properties ( ) : array Return an array of all the properties for this model. By default, returns every class variable.
query ( ) : Query Start a query to find models matching specific criteria.
save ( ) : integer Save this model to the database. Will create a new record if the ID property isn't set, or update an existing record if the ID property is set.
to_array ( ) : array Get all of the properties of this model as an array.

Method Details

__call() public méthode

Magically handle getters and setters.
public __call ( string $function, array $arguments ) : mixed
$function string
$arguments array
Résultat mixed

__construct() public méthode

Constructor.
public __construct ( array $properties = [] )
$properties array

all() public static méthode

Return EVERY instance of this model from the database, with NO filtering.
public static all ( ) : array
Résultat array

create() public static méthode

Create a new model from the given data.
public static create ( $properties ) : self
Résultat self

delete() public méthode

Delete the model from the database. Returns true if it was successful or false if it was not.
public delete ( ) : boolean
Résultat boolean

find_one() public static méthode

Find a specific model by it's unique ID.
public static find_one ( integer $id ) : false | self
$id integer
Résultat false | self

find_one_by() public static méthode

Find a specific model by a given property value.
public static find_one_by ( string $property, string $value ) : false | self
$property string
$value string
Résultat false | self

flatten_props() public méthode

Convert complex objects to strings to insert into the database.
public flatten_props ( array $props ) : array
$props array
Résultat array

get_primary_key() public static méthode

Get the column used as the primary key, defaults to 'id'.
public static get_primary_key ( ) : string
Résultat string

get_table_prefix() public méthode

Return configured table prefix.
public get_table_prefix ( ) : string
Résultat string

primary_key() public méthode

Return the value of the primary key.
public primary_key ( ) : integer
Résultat integer

properties() public méthode

Return an array of all the properties for this model. By default, returns every class variable.
public properties ( ) : array
Résultat array

query() public static méthode

Start a query to find models matching specific criteria.
public static query ( ) : Query
Résultat Query

save() public méthode

Save this model to the database. Will create a new record if the ID property isn't set, or update an existing record if the ID property is set.
public save ( ) : integer
Résultat integer

to_array() public méthode

Get all of the properties of this model as an array.
public to_array ( ) : array
Résultat array