Example of use of LudoDBTreeCollection
class TestNodesWithLeafs extends LudoDBTreeCollection implements LudoDBService{
protected $config = array(
"sql" => "select * from test_node order by parent,id",
"childKey" => "children",
"model" => "TestNode",
"fk" => "parent",
"pk" => "id",
"static" => array(
"type" => "node"
),
"merge" => array(
array(
"class" => "LeafNodes",
"fk" => "parent_node_id",
"pk" => "id"
)
)
);
public function validateArguments($service, $arguments){
return count($arguments) === 0;
}
public function validateServiceData($service, $data){
return true;
}
public function getValidServices(){
return array('read');
}
public function shouldCache($service){
return $service === "read";
}
}
Methods
Constructs a new LudoDBModel/LudoDBCollection
__construct()
Inherited
inherited_from |
\LudoDBObject::__construct() |
inherited_from |
\LudoDBIterator::__construct() |
inherited_from |
\LudoDBCollection::__construct() |
Return data as JSON string.
__toString() : string
Inherited
inherited_from |
\LudoDBObject::__toString() |
inherited_from |
\LudoDBIterator::__toString() |
inherited_from |
\LudoDBCollection::__toString() |
Returns
string
Return data as JSON.
asJSON() : string
Inherited
inherited_from |
\LudoDBObject::asJSON() |
inherited_from |
\LudoDBIterator::asJSON() |
inherited_from |
\LudoDBCollection::asJSON() |
Returns
string
Clear all cached config parsers
clearParsers()
InheritedStatic
inherited_from |
\LudoDBObject::clearParsers() |
inherited_from |
\LudoDBIterator::clearParsers() |
inherited_from |
\LudoDBCollection::clearParsers() |
Commit method implemented by sub classes.
commit()
Inherited
inherited_from |
\LudoDBObject::commit() |
inherited_from |
\LudoDBIterator::commit() |
inherited_from |
\LudoDBCollection::commit() |
Return reference to config parser.
configParser() : \LudoDBConfigParser | \LudoDBCollectionConfigParser
Inherited
inherited_from |
\LudoDBObject::configParser() |
inherited_from |
\LudoDBIterator::configParser() |
inherited_from |
\LudoDBCollection::configParser() |
Returns
Return current value when iterating collection
current() : mixed
Inherited
method |
current |
inherited_from |
\LudoDBIterator::current() |
inherited_from |
\LudoDBCollection::current() |
Returns
mixed
Delete all database records involved in this collection.
deleteRecords()
Inherited
This method requires that the collection
has arguments. Use LudoDB::deleteTab
inherited_from |
\LudoDBCollection::deleteRecords() |
Return
getCacheKey() : string
Inherited
inherited_from |
\LudoDBCollection::getCacheKey() |
Returns
string
Return array of values sent to constructor.
getConstructorValues() : array
Inherited
inherited_from |
\LudoDBObject::getConstructorValues() |
inherited_from |
\LudoDBIterator::getConstructorValues() |
inherited_from |
\LudoDBCollection::getConstructorValues() |
Returns
array
Implemented by sub classes.
getId() : null
Inherited
inherited_from |
\LudoDBObject::getId() |
inherited_from |
\LudoDBIterator::getId() |
inherited_from |
\LudoDBCollection::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() |
inherited_from |
\LudoDBCollection::getOnSuccessMessageFor() |
Parameters
$service
Returns
string
Returns reference to all tree nodes as numeric array
getRows() : Array
Inherited
inherited_from |
\LudoDBIterator::getRows() |
inherited_from |
\LudoDBCollection::getRows() |
Returns
Array
Return uncommitted data.
getUncommitted() : array
Inherited
This method is implemented in LudoDBModel.
inherited_from |
\LudoDBObject::getUncommitted() |
inherited_from |
\LudoDBIterator::getUncommitted() |
inherited_from |
\LudoDBCollection::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() |
inherited_from |
\LudoDBCollection::getValidServices() |
Returns
array
Return values in a tree structure
getValues() : array
Use $start and $count to specify a limit query.
Returns
array
Returns true if config is defined in external file.
hasConfigInExternalFile() : bool
Inherited
inherited_from |
\LudoDBObject::hasConfigInExternalFile() |
inherited_from |
\LudoDBIterator::hasConfigInExternalFile() |
inherited_from |
\LudoDBCollection::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() |
inherited_from |
\LudoDBCollection::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() |
inherited_from |
\LudoDBCollection::key() |
Returns
mixed
Go to next row.
next()
Inherited
inherited_from |
\LudoDBIterator::next() |
inherited_from |
\LudoDBCollection::next() |
Return data for this instance.
read() : mixed
Inherited
inherited_from |
\LudoDBObject::read() |
inherited_from |
\LudoDBIterator::read() |
inherited_from |
\LudoDBCollection::read() |
Returns
mixed
Rewind iterator, i.e.
rewind()
Inherited
inherited_from |
\LudoDBIterator::rewind() |
inherited_from |
\LudoDBCollection::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() |
inherited_from |
\LudoDBCollection::shouldCache() |
Parameters
$service
string
Returns
bool
Returns true when
valid() : bool
Inherited
inherited_from |
\LudoDBIterator::valid() |
inherited_from |
\LudoDBCollection::valid() |
Returns
bool
Clear database cache for this instance.
clearCache()
Inherited
inherited_from |
\LudoDBObject::clearCache() |
inherited_from |
\LudoDBIterator::clearCache() |
inherited_from |
\LudoDBCollection::clearCache() |
Clear internal row array
clearStoredRows()
Inherited
inherited_from |
\LudoDBIterator::clearStoredRows() |
inherited_from |
\LudoDBCollection::clearStoredRows() |
Escape constructor arguments.
escapeArguments($values) : array
Inherited
inherited_from |
\LudoDBObject::escapeArguments() |
inherited_from |
\LudoDBIterator::escapeArguments() |
inherited_from |
\LudoDBCollection::escapeArguments() |
Parameters
$values
Returns
array
Return values of a column as array
getColumnValues(String $column) : array
Inherited
inherited_from |
\LudoDBCollection::getColumnValues() |
Parameters
$column
String
Returns
array
Return config parser key of this class.
getConfigParserKey() : string
Inherited
inherited_from |
\LudoDBObject::getConfigParserKey() |
inherited_from |
\LudoDBIterator::getConfigParserKey() |
inherited_from |
\LudoDBCollection::getConfigParserKey() |
Returns
string
Return rows as associated array where key is the value of one column.
getRowsAssoc($key) : array
Inherited
inherited_from |
\LudoDBIterator::getRowsAssoc() |
inherited_from |
\LudoDBCollection::getRowsAssoc() |
Parameters
$key
Returns
array
Return values for a row using LudoDBModel as a parser/filter.
getValuesFromModel(\LudoDBModel $model, array $columns) : array
Inherited
inherited_from |
\LudoDBCollection::getValuesFromModel() |
Parameters
$columns
array
Returns
array
Merge in values from other collections
mergeInOthers()
Inherited
inherited_from |
\LudoDBCollection::mergeInOthers() |
On construct method which can be implemented by sub classes.
onConstruct()
Inherited
inherited_from |
\LudoDBObject::onConstruct() |
inherited_from |
\LudoDBIterator::onConstruct() |
inherited_from |
\LudoDBCollection::onConstruct() |
Return SQL handler
sqlHandler() : \LudoDBSql
Inherited
inherited_from |
\LudoDBObject::sqlHandler() |
inherited_from |
\LudoDBIterator::sqlHandler() |
inherited_from |
\LudoDBCollection::sqlHandler() |
Returns
Append current row to stored rows.
storeRow($row)
Inherited
inherited_from |
\LudoDBIterator::storeRow() |
inherited_from |
\LudoDBCollection::storeRow() |
Parameters
$row
Return a LudoDBCollection for a merged collection.
getCollectionInstance($className) : \LudoDBCollection
Inherited
inherited_from |
\LudoDBCollection::getCollectionInstance() |
Parameters
$className
Returns
Return values for a row in the collection using a LudoDBModel as filter/parser.
getValuesUsingModel(\LudoDBModel $model) : array
Inherited
This will be called when
"model" is set in the config.
inherited_from |
\LudoDBCollection::getValuesUsingModel() |
Parameters
Returns
array
Execute query and get result set reference.
load()
Inherited
inherited_from |
\LudoDBIterator::load() |
inherited_from |
\LudoDBCollection::load() |
Properties
$JSONConfig : bool
Inherited
inherited_from |
\LudoDBObject::$$JSONConfig |
inherited_from |
\LudoDBIterator::$$JSONConfig |
inherited_from |
\LudoDBCollection::$$JSONConfig |
$arguments : array
Inherited
This value
is used in join with config['constructBy']
inherited_from |
\LudoDBCollection::$$arguments |
$config : array
Inherited
example |
examples/cities/DemoCity.php |
inherited_from |
\LudoDBObject::$$config |
inherited_from |
\LudoDBIterator::$$config |
inherited_from |
\LudoDBCollection::$$config |
$configParsers : array
Inherited
inherited_from |
\LudoDBObject::$$configParsers |
inherited_from |
\LudoDBIterator::$$configParsers |
inherited_from |
\LudoDBCollection::$$configParsers |
$currentRow : array
Inherited
inherited_from |
\LudoDBIterator::$$currentRow |
inherited_from |
\LudoDBCollection::$$currentRow |
$db : \LudoDB
Inherited
inherited_from |
\LudoDBObject::$$db |
inherited_from |
\LudoDBIterator::$$db |
inherited_from |
\LudoDBCollection::$$db |
$configParserKey : string
Inherited
inherited_from |
\LudoDBObject::$$configParserKey |
inherited_from |
\LudoDBIterator::$$configParserKey |
inherited_from |
\LudoDBCollection::$$configParserKey |
$dbResource :
Inherited
inherited_from |
\LudoDBIterator::$$dbResource |
inherited_from |
\LudoDBCollection::$$dbResource |
$isValid :
Inherited
inherited_from |
\LudoDBIterator::$$isValid |
inherited_from |
\LudoDBCollection::$$isValid |
$loaded :
Inherited
inherited_from |
\LudoDBIterator::$$loaded |
inherited_from |
\LudoDBCollection::$$loaded |
$position : int
Inherited
inherited_from |
\LudoDBIterator::$$position |
inherited_from |
\LudoDBCollection::$$position |
$rows :
Inherited
inherited_from |
\LudoDBIterator::$$rows |
inherited_from |
\LudoDBCollection::$$rows |
$sql_handler : \LudoDBSql
Inherited
inherited_from |
\LudoDBObject::$$sql_handler |
inherited_from |
\LudoDBIterator::$$sql_handler |
inherited_from |
\LudoDBCollection::$$sql_handler |
$valueCache : array
Inherited
inherited_from |
\LudoDBIterator::$$valueCache |
inherited_from |
\LudoDBCollection::$$valueCache |