LudoDBCollection class.
Example of implementation:
With external config in JSON file:
PHP:
class People extends LudoDBCollection
{
protected $JSONConfig = true;
}
JSON in JSONConfig/People.json:
{
"model": "Person",
"sql": "select firstname, lastname, nick_name, p.zip,c.city from person p left join city c on c.zip = p.zip where p.zip=?",
"columns": ["firstname", "lastname", "nick_name","zip", "city"]
}
Example with internal PHP config:
class DemoCities extends LudoDBCollection
{
protected $config = array(
"sql" => "select * from demo_city order by name",
"model" => "DemoCity"
);
}
Methods
Constructs a new LudoDBModel/LudoDBCollection
__construct()
Inherited
inherited_from |
\LudoDBObject::__construct() |
inherited_from |
\LudoDBIterator::__construct() |
Return data as JSON string.
__toString() : string
Inherited
inherited_from |
\LudoDBObject::__toString() |
inherited_from |
\LudoDBIterator::__toString() |
Returns
string
Return data as JSON.
asJSON() : string
Inherited
inherited_from |
\LudoDBObject::asJSON() |
inherited_from |
\LudoDBIterator::asJSON() |
Returns
string
Clear all cached config parsers
clearParsers()
InheritedStatic
inherited_from |
\LudoDBObject::clearParsers() |
inherited_from |
\LudoDBIterator::clearParsers() |
Commit method implemented by sub classes.
commit()
Inherited
inherited_from |
\LudoDBObject::commit() |
inherited_from |
\LudoDBIterator::commit() |
Return current value when iterating collection
current() : mixed
Inherited
method |
current |
inherited_from |
\LudoDBIterator::current() |
Returns
mixed
Delete all database records involved in this collection.
deleteRecords()
This method requires that the collection
has arguments. Use LudoDB::deleteTab
Return
getCacheKey() : string
Return array of values sent to constructor.
getConstructorValues() : array
Inherited
inherited_from |
\LudoDBObject::getConstructorValues() |
inherited_from |
\LudoDBIterator::getConstructorValues() |
Returns
array
Implemented by sub classes.
getId() : null
Inherited
inherited_from |
\LudoDBObject::getId() |
inherited_from |
\LudoDBIterator::getId() |
Returns
null
LudoDBService getOnSuccessMessageFor method.
getOnSuccessMessageFor($service) : string
Inherited
By default, it returns an empty string.
inherited_from |
\LudoDBObject::getOnSuccessMessageFor() |
inherited_from |
\LudoDBIterator::getOnSuccessMessageFor() |
Parameters
$service
Returns
string
Returns reference to all tree nodes as numeric array
getRows() : Array
Inherited
inherited_from |
\LudoDBIterator::getRows() |
Returns
Array
Return uncommitted data.
getUncommitted() : array
Inherited
This method is implemented in LudoDBModel.
inherited_from |
\LudoDBObject::getUncommitted() |
inherited_from |
\LudoDBIterator::getUncommitted() |
Returns
array
Valid public services offered by this class, example "read", "delete" and "save"
getValidServices() : array
Inherited
inherited_from |
\LudoDBObject::getValidServices() |
inherited_from |
\LudoDBIterator::getValidServices() |
Returns
array
Return collection values.
getValues(null $start, null $count) : array
Use $start and $count to specify a limit query.
Parameters
$start
null
$count
null
Returns
array
Returns true if config is defined in external file.
hasConfigInExternalFile() : bool
Inherited
inherited_from |
\LudoDBObject::hasConfigInExternalFile() |
inherited_from |
\LudoDBIterator::hasConfigInExternalFile() |
Returns
bool
Returns true if database table has rows where one of the given columns has one of the
given values.
hasRowWith(array $columnsEqual)
Inherited
Example:
if($this->hasRowWith(array("email" => "name@dhtmlgoodies.com"));
inherited_from |
\LudoDBObject::hasRowWith() |
inherited_from |
\LudoDBIterator::hasRowWith() |
Parameters
$columnsEqual
array
Return key used for iterator.
key() : mixed
Inherited
method |
key |
example |
function key(){
return $this->currentRow['key']
}
to return key |
inherited_from |
\LudoDBIterator::key() |
Returns
mixed
Go to next row.
next()
Inherited
inherited_from |
\LudoDBIterator::next() |
Return data for this instance.
read() : mixed
Inherited
inherited_from |
\LudoDBObject::read() |
inherited_from |
\LudoDBIterator::read() |
Returns
mixed
Rewind iterator, i.e.
rewind()
Inherited
inherited_from |
\LudoDBIterator::rewind() |
When handled by LudoDBRequestHandler no services will by default be cached.
shouldCache(string $service) : bool
Inherited
This method should
be implemented by sub classes when needed.
inherited_from |
\LudoDBObject::shouldCache() |
inherited_from |
\LudoDBIterator::shouldCache() |
Parameters
$service
string
Returns
bool
Returns true when
valid() : bool
Inherited
inherited_from |
\LudoDBIterator::valid() |
Returns
bool
Clear database cache for this instance.
clearCache()
Inherited
inherited_from |
\LudoDBObject::clearCache() |
inherited_from |
\LudoDBIterator::clearCache() |
Clear internal row array
clearStoredRows()
Inherited
inherited_from |
\LudoDBIterator::clearStoredRows() |
Escape constructor arguments.
escapeArguments($values) : array
Inherited
inherited_from |
\LudoDBObject::escapeArguments() |
inherited_from |
\LudoDBIterator::escapeArguments() |
Parameters
$values
Returns
array
Return values of a column as array
getColumnValues(String $column) : array
Parameters
$column
String
Returns
array
Return config parser key of this class.
getConfigParserKey() : string
Inherited
inherited_from |
\LudoDBObject::getConfigParserKey() |
inherited_from |
\LudoDBIterator::getConfigParserKey() |
Returns
string
Return rows as associated array where key is the value of one column.
getRowsAssoc($key) : array
Inherited
inherited_from |
\LudoDBIterator::getRowsAssoc() |
Parameters
$key
Returns
array
Return values for a row using LudoDBModel as a parser/filter.
getValuesFromModel(\LudoDBModel $model, array $columns) : array
Parameters
$columns
array
Returns
array
Merge in values from other collections
mergeInOthers()
On construct method which can be implemented by sub classes.
onConstruct()
Inherited
inherited_from |
\LudoDBObject::onConstruct() |
inherited_from |
\LudoDBIterator::onConstruct() |
Return SQL handler
sqlHandler() : \LudoDBSql
Inherited
inherited_from |
\LudoDBObject::sqlHandler() |
inherited_from |
\LudoDBIterator::sqlHandler() |
Returns
Append current row to stored rows.
storeRow($row)
Inherited
inherited_from |
\LudoDBIterator::storeRow() |
Parameters
$row
Return a LudoDBCollection for a merged collection.
getCollectionInstance($className) : \LudoDBCollection
Parameters
$className
Returns
Return values for a row in the collection using a LudoDBModel as filter/parser.
getValuesUsingModel(\LudoDBModel $model) : array
This will be called when
"model" is set in the config.
Parameters
Returns
array
Execute query and get result set reference.
load()
Inherited
inherited_from |
\LudoDBIterator::load() |
Properties
$JSONConfig : bool
Inherited
inherited_from |
\LudoDBObject::$$JSONConfig |
inherited_from |
\LudoDBIterator::$$JSONConfig |
$arguments : array
This value
is used in join with config['constructBy']
$config : array
Inherited
example |
examples/cities/DemoCity.php |
inherited_from |
\LudoDBObject::$$config |
inherited_from |
\LudoDBIterator::$$config |
$configParsers : array
Inherited
inherited_from |
\LudoDBObject::$$configParsers |
inherited_from |
\LudoDBIterator::$$configParsers |
$currentRow : array
Inherited
inherited_from |
\LudoDBIterator::$$currentRow |
$db : \LudoDB
Inherited
inherited_from |
\LudoDBObject::$$db |
inherited_from |
\LudoDBIterator::$$db |
$configParserKey : string
Inherited
inherited_from |
\LudoDBObject::$$configParserKey |
inherited_from |
\LudoDBIterator::$$configParserKey |
$dbResource :
Inherited
inherited_from |
\LudoDBIterator::$$dbResource |
$isValid :
Inherited
inherited_from |
\LudoDBIterator::$$isValid |
$loaded :
Inherited
inherited_from |
\LudoDBIterator::$$loaded |
$position : int
Inherited
inherited_from |
\LudoDBIterator::$$position |
$rows :
Inherited
inherited_from |
\LudoDBIterator::$$rows |
$sql_handler : \LudoDBSql
Inherited
inherited_from |
\LudoDBObject::$$sql_handler |
inherited_from |
\LudoDBIterator::$$sql_handler |
$valueCache : array
Inherited
inherited_from |
\LudoDBIterator::$$valueCache |