AloFramework documentation
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • Alo
    • Cache
    • CLI
    • Controller
    • Db
      • Query
    • Exception
    • FileSystem
    • Session
    • Traversables
    • Validators
    • Windows
  • Controller
  • None
  • PHP

Classes

  • AbstractDb
  • MySQL
  • Resultset

Class Resultset

SQL resultset handler. The resultset must be in array form, i.e. an array of associative arrays

Alo\Traversables\ArrayObjimplementsIteratorAggregate,ArrayAccess,Countable
Extended byAlo\Db\Resultset
Namespace:Alo\Db
Author:Art <a.molcanovas@gmail.com>
Located atsys/class/alo/db/resultset.php

Methods summary

public
#__construct(array$resultset)

Initialises our resultset handler

Initialises our resultset handler

Parameters

$resultset
array
$resultset The resultset returned

Author

Art <a.molcanovas@gmail.com>

Overrides

Alo\Traversables\ArrayObj::__construct
public array
#getWhere(array$spec,integer$limit= PHP_INT_MAX)

Get values matching the filter

Get values matching the filter

Parameters

$spec
array
$spec The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of rows to match

Returns

array

Author

Art <a.molcanovas@gmail.com>
protected static boolean
#compare(mixed$value,string$modifier,mixed$modValue)

Checks if a the row column matches the filter

Checks if a the row column matches the filter

Parameters

$value
mixed
$value The value in the row
$modifier
string
$modifier The modifier ('=','>', '>=' etc)
$modValue
mixed
$modValue What the modifier is checking against

Returns

boolean

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#keepWhere(array$spec,integer$limit= PHP_INT_MAX)

Only keeps vallues in the resultset that match the filter

Only keeps vallues in the resultset that match the filter

Parameters

$spec
array
$spec The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of rows to match

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#deleteWhere(array$spec)

Deletes values from the resultset that match the filter

Deletes values from the resultset that match the filter

Parameters

$spec
array
$spec The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
protected array &
#getWhereReferential(array$spec)

A clone of getWhere() that returns references to the rows in the dataset instead of a new array

A clone of getWhere() that returns references to the rows in the dataset instead of a new array

Parameters

$spec
array
$spec The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]

Returns

array

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#setValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Sets the value(s) on columns that match the filter

Sets the value(s) on columns that match the filter

Parameters

$sets
array
$sets Array of values to set where the keys are the column names and the values are the values to set
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of rows to modify

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
public boolean|mixed
#applyCallbackWhere(callable$callable,array$where=null)

Applies a callback to the rows matching the filter. This will modify the data in the object.

Applies a callback to the rows matching the filter. This will modify the data in the object.

Parameters

$callable
callable
$callable The callback function. It should accept the first parameter which is the array of associative arrays that matches the filter.
$where
array
$where

Returns

boolean|mixed
false if $callable isn't callable or whatever your callback returns.

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#appendValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Appends values in the resultset

Appends values in the resultset

Parameters

$sets
array
$sets Array of values to append where the keys are the column names and the values are the strings to append
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maxumum number of affected rows

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#prependValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Prepends values in the resultset

Prepends values in the resultset

Parameters

$sets
array
$sets Array of values to prepend where the keys are the column names and the values are the strings to prepend
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of affected rows

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#incrementValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Increments a numeric value(or values) in the resultset

Increments a numeric value(or values) in the resultset

Parameters

$sets
array
$sets The increment specs, where the keys are the columns to modify and the values are how much to increment by
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maxumum number of affected rows

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#decrementValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Decrements a numeric value(or values) in the resultset

Decrements a numeric value(or values) in the resultset

Parameters

$sets
array
$sets The decrement specs where the keys are the columns to modify and the values are how much to decrement by
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of affected rows

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#multiplyValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Multiplies numeric values in the resultset

Multiplies numeric values in the resultset

Parameters

$sets
array
$sets The multiplication specs where the keys are columns to modify and the values are how much to multiply by
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of affected rows

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
publicAlo\Db\Resultset
#divideValue(array$sets,array$where=null,integer$limit= PHP_INT_MAX)

Divides numeric values in the resultset

Divides numeric values in the resultset

Parameters

$sets
array
$sets The division specs where the keys are columns to modify and the values are how much divide by
$where
array
$where The filter associative array where the keys are column names and the values are [modifier,value]. For example to get rows where the column "foo" is greater than 5 and the column "bar" equals "qux" pass the array ['foo' => ['>',5], 'bar' => ['=', 'qux']]
$limit
integer
$limit Maximum number of affected rows

Returns

Alo\Db\Resultset

Author

Art <a.molcanovas@gmail.com>
public array|boolean|string
#toInsertStatement(string$tableName,string$insertType='INSERT',boolean$withBoundParams=true)

Transforms the dataset into an insert statement

Transforms the dataset into an insert statement

Parameters

$tableName
string
$tableName Which what table to insert to
$insertType
string
$insertType Insert type. Can be INSERT or REPLACE
$withBoundParams
boolean
$withBoundParams If set to true (recommended) will produce an array [sql_query_for_prepare_statement,array_of_bound_parameters]; if set to false will generate a simple unescaped insert query which should only be used for internal testing

Returns

array|boolean|string
false if the data array is empty or the insert type is invalid, the SQL query string if $withBoundParams is false, [sql_query_for_prepare_statement,array_of_bound_parameters] array if $withBoundParams is true

Author

Art <a.molcanovas@gmail.com>

Methods inherited fromAlo\Traversables\ArrayObj

__get(),__set(),count(),getIterator(),offsetExists(),offsetGet(),offsetSet(),offsetUnset(),toArray()

Magic methods summary

Constants summary

stringMOD_EQUALS'='
#

Defines a modifier as "equals"

Defines a modifier as "equals"

stringMOD_NOT_EQUALS'!='
#

Defines a modifier as "doesn't equal"

Defines a modifier as "doesn't equal"

stringMOD_GT'>'
#

Defines a modifier as "greater than"

Defines a modifier as "greater than"

stringMOD_GET'>='
#

Defines a modifier as "greater than or equal to"

Defines a modifier as "greater than or equal to"

stringMOD_LT'<'
#

Defines a modifier as "lower than"

Defines a modifier as "lower than"

stringMOD_LET'<='
#

Defines a modifier as "lower than or equal to"

Defines a modifier as "lower than or equal to"

Properties summary

Properties inherited fromAlo\Traversables\ArrayObj

$data

AloFramework documentation API documentation generated byApiGen 2.8.0