Class

SQLDAO

Abstract Package: MVC\Model Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Loic ROUCHON horn@phpboost.com Version: PHPBoost 5.2 - last update: 2014 12 22 Since: PHPBoost 3.0 - 2009 10 02 Located at: mvc/model/SQLDAO.class.php

Implements common access to a sql based datastore for CRUD operations on objects attached to the given

MappingModel

.

SQLDAO implements DAO
Methods summary
public
# __construct( MappingModel $model, SQLQuerier $querier = null )

initialize the dao

public
# save( PropertiesMapInterface $object )

Saves

$object

in the table. If the object does not exist, it is created, else, just updated

public
# update( array $fields, string $where = DAO::WHERE_ALL, array $parameters = array() )

Update all fields in the table to the given value if row match the where clause.

public
# delete( PropertiesMapInterface $object )

Deletes

$object

from the table. If the object does not exist, nothing is done

public
# delete_all( string $where = DAO::WHERE_ALL, array $parameters = array() )

Deletes all object matching the where clause from the table.

public
# count( string $where = DAO::WHERE_ALL, array $parameters = array() )

Count the number of object in the table matching the

$where

clause

public PropertiesMapInterface
# find_by_id( mixed $id )

retrieves the object with the

$id

primary identifier

public QueryResultMapper
# find_all( integer $limit = DAO::FIND_ALL, integer $offset = 0, string[mixed][] $order_by = array() )

retrieves the

$limit

first objects from the

$offset

one. If

$order_by

is specified, objects will be sorted in the

$way

way

public QueryResultMapper
# find_by_criteria( string $criteria, string[string] $parameters = array() )

retrieves all the objects in the table matching the

$criteria
Constants inherited from DAO
FIND_ALL, WHERE_ALL
Properties summary
protected DBQuerier $querier

the sql querier that will interact with the database

#
protected MappingModel $model

the model on which services are based

#
protected string $table

the name of the table in which objects will be stored

#
protected string $pk_db_field

the primary key database field name (prefixed by the table name)

#
protected string $pk_property

the primary key property

#
protected string $pk_getter

the primary key getter method name

#
protected string $pk_setter

the primary key setter method name

#
protected string[string] $fields_mapping

$fields_mapping[$property] => $db_field_name

# array()
protected string $delete_query

the delete prepared query

#
protected string $insert_query

the insert prepared query

#
protected string $update_query

the update prepared query

#
protected string $find_by_id_query

the find by id prepared query

#
protected string $find_by_criteria_query

the find by criteria prepared query

#
Annonces