\Hazaar\DBI
Table
Relational Database Interface - Table Class

The Table class is used to access table data via an abstracted interface. That means that now SQL is used to access table data and queries are generated automatically using access methods. The generation of SQL is then handled by the database driver so that database specific SQL can be used when required. This allows a common interface for accessing data that is compatible across all of the database drivers.

Example Usage

$db = new Hazaar\DBI(); $result = $db->users->find(array('uname' => 'myusername'))->join('images', array('image' => array('$ref' => 'images.id'))); while($row = $result->fetch()){ //Do things with $row here }

Summary
Methods Properties Constants
all
key
row
No constants
Properties
$alias
$alias
$criteria
$criteria
$driver
$driver
$fields
$fields
$group
$group
$having
$having
$joins
$joins
$limit
$limit
$name
$name
$offset
$offset
$order
$order
$result
$result
Methods
__construct()
__construct($driver, $name, $alias = null)

Parameters

$driver\Hazaar\DBI\DBD\BaseDriver

No description

$name

No description

$alias

No description

__tostring()
__tostring()
all()
all()
collate()
collate($index_column, $value_column, $group_column = null) : array
Collates a result into a simple key/value array.

This is useful for generating SELECT lists directly from a resultset.

Parameters

$index_columnmixed

The column to use as the array index.

$value_columnmixed

The column to use as the array value.

$group_columnmixed

Optional column name to group items by.

Returns

array
count()
count()
current()
current()
delete()
delete($criteria)

Parameters

$criteria

No description

deleteAll()
deleteAll()
execute()
execute() : Result
Execute the current selection

Tags

Throws

\Exception

exists()
exists($criteria = null) : bool
Check if rows exist in the database

Parameters

$criteriamixed

The search criteria to check for existing rows.

Returns

\Hazaar\DBI\bool
fetch()
fetch($offset = 0)

Parameters

$offset

No description

fetchAll()
fetchAll()
fields()
fields($fields) : Table
Defined the current field selection definition

Parameters

$fieldsmixed

A valid field definition

Returns

\Hazaar\DBI\Table
find()
find($criteria = Array ( ) , $fields = Array ( ) ) : Table
Search for records on a table with the provided search criteria

Parameters

$criteriamixed

The search criteria to find records for.

$fieldsmixed

A field definition.

Returns

\Hazaar\DBI\Table
findOne()
findOne($criteria = Array ( ) , $fields = Array ( ) , $order = null) : mixed
Find a single row using the provided criteria, fields and order and return is as an array.

Parameters

$criteriamixed

The search criteria.

$fieldsmixed

A field definition array.

$ordermixed

A valid order definition

Returns

mixed
from()
from()
fullJoin()
fullJoin($references, $on = Array ( ) , $alias = null)

Parameters

$references

No description

$on

No description

$alias

No description

getResult()
getResult()
group()
group($columns)

Parameters

$columns

No description

having()
having($criteria)

Parameters

$criteria

No description

innerJoin()
innerJoin($references, $on = Array ( ) , $alias = null)

Parameters

$references

No description

$on

No description

$alias

No description

insert()
insert($fields, $returning = null)

Parameters

$fields

No description

$returning

No description

join()
join($references, $on = Array ( ) , $alias = null, $type = 'INNER') : Table
Join a table to the current query using the provided join criteria.

Parameters

$referencesstring

The table to join to the query.

$onarray

The join criteria. This is mostly just a standard query selection criteria.

$aliasstring

An alias to use for the joined table.

$typestring

The join type such as INNER, OUTER, LEFT, RIGHT, etc.

Returns

\Hazaar\DBI\Table
key()
key()
leftJoin()
leftJoin($references, $on = Array ( ) , $alias = null)

Parameters

$references

No description

$on

No description

$alias

No description

limit()
limit($limit = 1)

Parameters

$limit

No description

next()
next()
offset()
offset($offset)

Parameters

$offset

No description

offsetExists()
offsetExists($offset)

Parameters

$offset

No description

offsetGet()
offsetGet($offset)

Parameters

$offset

No description

offsetSet()
offsetSet($offset, $value)

Parameters

$offset

No description

$value

No description

offsetUnset()
offsetUnset($offset)

Parameters

$offset

No description

reset()
reset()
rewind()
rewind()
rightJoin()
rightJoin($references, $on = Array ( ) , $alias = null)

Parameters

$references

No description

$on

No description

$alias

No description

row()
row()
select()
select($fields) : Table
Alias for Hazaar\DBI\Table::fields()

Parameters

$fieldsmixed

One or more column names

Returns

\Hazaar\DBI\Table
sort()
sort($field_def, $desc = false)

Parameters

$field_def

No description

$desc

No description

toString()
toString($terminate_with_colon = true) : string
Return the current selection as a valid SQL string

Parameters

$terminate_with_colonmixed

No description

Returns

string
update()
update($criteria, $fields)

Parameters

$criteria

No description

$fields

No description

valid()
valid()
where()
where($criteria) : Table
Defines a WHERE selection criteria

Parameters

$criteriamixed

No description

Returns

\Hazaar\DBI\Table