$qb
$qb : \Pixie\QueryBuilder\QueryBuilderHandler
QueryBuilder instance
Model abstraction
$aliases : array
Aliases to convert from client data format to server format
Aliases should be an array with the keys representing the client side format and the values representing the server side.
E.G. Client property = 'id' Server property = 'userID'
$aliases = array('id'=>'userID')
forge(array $initialValues = array()) : \Pixie\QueryBuilder\QueryBuilderHandler
Initiates the model. Sets the "fields" variable if it exists
array | $initialValues | optional array of inital values to add to the query |
QueryBuilder instance associated with the object
findOne(array $searchValues, array $includes = array(), array $fields = array(), boolean $runFilters = true) : \FW\Data\Standard\Model
Find one model record
array | $searchValues | Values to search by (associative array) Prefix the key with ! for not equals check NOTE: if one of the values in the key-value pair is an array, it will be treated as an 'IN' check instead of an '=' check |
array | $includes | Joinable relationships to include |
array | $fields | List of fields to return |
boolean | $runFilters | If false, skip running filters. Used internally by add, edit, and editMany to prevent the returns from being caught For example, if we edit based on a filter, the returns may no longer match the filter |
Values from the database as a Model object
findAll(array $searchValues, array $includes = array(), array $fields = array(), boolean $runFilters = true) : array
Find all the model records
array | $searchValues | Values to search by (associative array) Prefix the key with ! for not equals check NOTE: if one of the values in the key-value pair is an array, it will be treated as an 'IN' check instead of an '=' check |
array | $includes | Joinable relationships to include |
array | $fields | List of fields to return |
boolean | $runFilters | If false, skip running filters. Used internally by add, edit, and editMany to prevent the returns from being caught For example, if we edit based on a filter, the returns may no longer match the filter |
Array of model classes
count(array $searchValues) : integer
Gets a count of record models for the specified search. Useful for pagination
array | $searchValues | Values to search by (associative array) Prefix the key with ! for not equals check NOTE: if one of the values in the key-value pair is an array, it will be treated as an 'IN' check instead of an '=' check |
Number of results
findById(mixed $id, array $includes = array(), array $fields = array()) : mixed|null
Convenience method used to find a singe record via the record's primary key
mixed | $id | Value in the primary key column to check |
array | $includes | Relationships to include |
array | $fields |
model record, or null if not found
add(array $values, array $includes = array()) : \FW\Data\Standard\Model
Adds a new record to the database
array | $values | Values to add |
array | $includes | Includes to include |
The newly added model class
updateMany(array $valuesArray, array $includes = array()) : array
Saves many models in one large database request. Handles editing or adding automatically.
Note it does not handle editing setting a value to null for technical reasons, so if values may change to and from null a different method should be used
array | $valuesArray | Array of model JSON. Same format as edit or add, but one per model changing |
array | $includes | Any relationships to include in the output. Note that relationships cannot be saved using this |
Array of models that were added or edited
edit(string|integer $id, array $values, array $includes = array()) : \FW\Data\Standard\Model
Edits an existing database record
string|integer | $id | Primary Key of model record |
array | $values | Values to update |
array | $includes | Joins to include in select |
Updated Model object
editMany(array $searchValues, array $values, array $includes = array(), array $fields = array()) : array
Find all the model records
array | $searchValues | Values to search by (associative array) Prefix the key with ! for not equals check NOTE: if one of the values in the key-value pair is an array, it will be treated as an 'IN' check instead of an '=' check |
array | $values | Values to update |
array | $includes | Joinable relationships to include |
array | $fields |
Array of model classes
deleteMany(array $searchValues, $includes = array(), array $fields = array())
Deletes multiple model records based on a search filter
array | $searchValues | Values to search by (associative array) Prefix the key with ! for not equals check NOTE: if one of the values in the key-value pair is an array, it will be treated as an 'IN' check instead of an '=' check |
$includes | ||
array | $fields |
joinMany(\Pixie\QueryBuilder\QueryBuilderHandler $qb, string $name, string $table, string $key, boolean $isToMany = true, \Closure $joinOn = null, string $id = null)
Concise way of joining another table based on id comparison
\Pixie\QueryBuilder\QueryBuilderHandler | $qb | QueryBuilder instance |
string | $name | name of generated column of ids |
string | $table | table name (without prefix if one exists) |
string | $key | id column name of table to compare |
boolean | $isToMany | if the relationship is one-to-many, this will be set to false |
\Closure | $joinOn | if there are extra join rules use them |
string | $id | id column name of the current table in the join |
insertMany(\Pixie\QueryBuilder\QueryBuilderHandler $qb, string $table, string $key, string|integer $id, array $values)
Handles the insert/update side of the relationship based on id comparison
Used in many-to-many relationships
\Pixie\QueryBuilder\QueryBuilderHandler | $qb | QueryBuilder Instance |
string | $table | Table name (without prefix) |
string | $key | id column name of $table |
string|integer | $id | ID of current row |
array | $values | Array of values to be placed in the join table |
prefixForeignKey(string|array $values, string $prefix = 'FK_') : string|array
Prefixes $values with a predefined foreign key prefix
string|array | $values | String or array of strings to prefix |
string | $prefix | string to prefix with |
String or array of prefixed values
findProcess(\Pixie\QueryBuilder\QueryBuilderHandler $qb, array $searchValues, array $includes, array $fields)
Helper used by findOne and findAll to handle some of the join and search legwork
\Pixie\QueryBuilder\QueryBuilderHandler | $qb | QueryBuilder instance |
array | $searchValues | Values to search by |
array | $includes | Relationships to include |
array | $fields | Array of fields to return |