Cache class used by LudoDBRequestHandler.
This is a LudoDBModel storing data as serialized
strings in the database. When caching is enabled for a service, LudoDBRequestHandler will
attempt to retrieve data from cache before calling the service method. This may save time
for services requiring many SQL queries to complete.
Methods
Creates magic get and set methods for columns.
__call($name, $arguments) : null
Inherited
Example
columns "firstname" will have it's own "getFirstname" and "setFirstname" method.
inherited_from |
\LudoDBModel::__call() |
Parameters
$name
$arguments
Exceptions
Returns
null
Creates new LudoDBCache instance.
__construct(\LudoDBService $resource, array $arguments)
An empty LudoDBService class is sent to the constructor along
with constructor arguments. The cache class will search for records where "class_name" equals
class of given service and arguments compiled to a key matches cache_key in the database table.
Parameters
$arguments
array
Return data as JSON string.
__toString() : string
Inherited
inherited_from |
\LudoDBObject::__toString() |
inherited_from |
\LudoDBModel::__toString() |
Returns
string
Return data as JSON.
asJSON() : string
Inherited
inherited_from |
\LudoDBObject::asJSON() |
inherited_from |
\LudoDBModel::asJSON() |
Returns
string
Clear cache records from db where cache_key equals key
clearBy(string $key)
Static
Clear all cache record for given class name / resource.
clearByClass($className)
Static
Clear all cached config parsers
clearParsers()
InheritedStatic
inherited_from |
\LudoDBObject::clearParsers() |
inherited_from |
\LudoDBModel::clearParsers() |
Clear data from model.
clearValues()
Inherited
inherited_from |
\LudoDBModel::clearValues() |
Commit changes to the database.
commit() : null | void
Inherited
Example:
$person = new Person();
$person->setFirstname('John');
$person->setLastname('Johnson');
$person->commit();
echo $person->getId();
inherited_from |
\LudoDBModel::commit() |
Returns
null
void
Create DB table
createTable()
Inherited
inherited_from |
\LudoDBModel::createTable() |
Delete record
delete()
Inherited
inherited_from |
\LudoDBModel::delete() |
Delete all data from this table.
deleteTableData() : \LudoDBModel
Inherited
You need to call yesImSure afterwards.
Example:
$person = new Person();
$person->deleteTableData()->yesImSure();
inherited_from |
\LudoDBModel::deleteTableData() |
Returns
Disable commit for this object
disableCommit()
Inherited
inherited_from |
\LudoDBModel::disableCommit() |
Drop database table.
drop()
Inherited
You need to call yesImSure afterwards.
Example:
$person = new Person();
$person->drop()->yesImSure();
inherited_from |
\LudoDBModel::drop() |
Enable commit for this object.
enableCommit()
Inherited
commit is by default enabled
inherited_from |
\LudoDBModel::enableCommit() |
Returns true if database table exists.
exists() : bool
Inherited
inherited_from |
\LudoDBModel::exists() |
Returns
bool
Return cache data
getCache() : array
Return array of values sent to constructor.
getConstructorValues() : array
Inherited
inherited_from |
\LudoDBObject::getConstructorValues() |
inherited_from |
\LudoDBModel::getConstructorValues() |
Returns
array
Return id of current record.
getId() : string | int | null
Inherited
inherited_from |
\LudoDBModel::getId() |
Returns
string
int
null
LudoDBService getOnSuccessMessageFor method.
getOnSuccessMessageFor($service) : string
Inherited
By default, it returns an empty string.
inherited_from |
\LudoDBObject::getOnSuccessMessageFor() |
inherited_from |
\LudoDBModel::getOnSuccessMessageFor() |
Parameters
$service
Returns
string
Return model values.
getSomeValues(array $keys) : array
Inherited
inherited_from |
\LudoDBModel::getSomeValues() |
Parameters
$keys
array
Returns
array
Return key-pair values with null values removed.
getSomeValuesFiltered(array $keys) : array
Inherited
inherited_from |
\LudoDBModel::getSomeValuesFiltered() |
Parameters
$keys
array
Returns
array
Return uncommited data
getUncommitted() : array
Inherited
This method is implemented in LudoDBModel.
inherited_from |
\LudoDBModel::getUncommitted() |
Returns
array
Valid public services offered by this class, example "read", "delete" and "save"
getValidServices() : array
Inherited
inherited_from |
\LudoDBObject::getValidServices() |
inherited_from |
\LudoDBModel::getValidServices() |
Returns
array
Return value of public columns
getValues() : array
Inherited
inherited_from |
\LudoDBModel::getValues() |
Returns
array
Returns true if config is defined in external file.
hasConfigInExternalFile() : bool
Inherited
inherited_from |
\LudoDBObject::hasConfigInExternalFile() |
inherited_from |
\LudoDBModel::hasConfigInExternalFile() |
Returns
bool
Returns true if cache data exists.
hasData() : 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 |
\LudoDBModel::hasRowWith() |
Parameters
$columnsEqual
array
Return true if update and save is allowed to run.
isValid() : bool
Inherited
inherited_from |
\LudoDBModel::isValid() |
Returns
bool
Return data for this instance.
read() : mixed
Inherited
inherited_from |
\LudoDBObject::read() |
inherited_from |
\LudoDBModel::read() |
Returns
mixed
Rollback updates
rollback()
Inherited
inherited_from |
\LudoDBModel::rollback() |
Populate and save data.
save($data) : array
Inherited
Returns array "" => ""
Example:
$city = new City();
$data = $city->save(array("city" => "Stavanger", "country" => "Norway"));
var_dump($data);
inherited_from |
\LudoDBModel::save() |
Parameters
$data
Returns
array
Store service data to cache
setCache(array $json) : \LudoDBCache
Parameters
$json
array
Returns
Set cache_key of new cache record
setKey($key) : \LudoDBCache
Populate columns you can write to with these data
setValues($data) : bool
Inherited
example |
:
$person = new Person(1);
$person->populate(array(
"firstname" => "Jane", "lastname" => "Johnson"
));
$person->commit();
|
inherited_from |
\LudoDBModel::setValues() |
Parameters
$data
Returns
bool
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 |
\LudoDBModel::shouldCache() |
Parameters
$service
string
Returns
bool
Executes drop or deleteTableData
yesImSure()
Inherited
example |
$p = new Person();
$p->drop()->yesImSure(); |
inherited_from |
\LudoDBModel::yesImSure() |
Method executed before new record is saved in db
beforeInsert()
Inherited
inherited_from |
\LudoDBModel::beforeInsert() |
Method executed before record is updated
beforeUpdate()
Inherited
inherited_from |
\LudoDBModel::beforeUpdate() |
Clear database cache for this instance.
clearCache()
Inherited
inherited_from |
\LudoDBObject::clearCache() |
inherited_from |
\LudoDBModel::clearCache() |
Escape constructor arguments.
escapeArguments($values) : array
Inherited
inherited_from |
\LudoDBObject::escapeArguments() |
inherited_from |
\LudoDBModel::escapeArguments() |
Parameters
$values
Returns
array
Return config parser instance.
getConfigParserInstance() : \LudoDBConfigParser
Inherited
inherited_from |
\LudoDBObject::getConfigParserInstance() |
inherited_from |
\LudoDBModel::getConfigParserInstance() |
Returns
Return config parser key of this class.
getConfigParserKey() : string
Inherited
inherited_from |
\LudoDBObject::getConfigParserKey() |
inherited_from |
\LudoDBModel::getConfigParserKey() |
Returns
string
Return valid value for argument with given name
getValidArgument($key, $value) : mixed
Inherited
inherited_from |
\LudoDBModel::getValidArgument() |
Parameters
$key
$value
Returns
mixed
Return column value.
getValue($column) : null
Inherited
This method will return
* Uncommitted value if exists or value from db
* Value from external models/collection
* Value of static columns
* Default values.
Example:
public function getFirstname(){
return $this->getValue('firstname');
}
inherited_from |
\LudoDBModel::getValue() |
Parameters
$column
Returns
null
Populate database table with default data defined in table config
insertDefaultData()
Inherited
inherited_from |
\LudoDBModel::insertDefaultData() |
On construct method which can be implemented by sub classes.
onConstruct()
Inherited
inherited_from |
\LudoDBObject::onConstruct() |
inherited_from |
\LudoDBModel::onConstruct() |
Populate with data from db
populate()
Inherited
inherited_from |
\LudoDBModel::populate() |
Update id field
setId($id)
Inherited
inherited_from |
\LudoDBModel::setId() |
Parameters
$id
Set a column value.
setValue($column, $value) : null
Inherited
This value will not be committed to db until
a call to commit is made.
Example:
public function setFirstName($name){
$this->setValue('firstname', $name');
}
inherited_from |
\LudoDBModel::setValue() |
Parameters
$column
$value
Returns
null
Return SQL handler
sqlHandler() : \LudoDBSql
Inherited
inherited_from |
\LudoDBObject::sqlHandler() |
inherited_from |
\LudoDBModel::sqlHandler() |
Returns
Auto populate model with data from db.
autoPopulate()
Inherited
inherited_from |
\LudoDBModel::autoPopulate() |
Execute commit on classes for external columns.
commitExternal(\LudoDBObject $class)
Inherited
inherited_from |
\LudoDBModel::commitExternal() |
Parameters
Create database indexes defined in table config
createIndexes()
Inherited
inherited_from |
\LudoDBModel::createIndexes() |
Return cache key based on class name and arguments.
getCacheKey($resourceName, $arguments) : string
Parameters
$resourceName
$arguments
Returns
string
Return external class reference for external column
getExternalClassFor(String $column) : \LudoDBCollection
Inherited
inherited_from |
\LudoDBModel::getExternalClassFor() |
Parameters
$column
String
Returns
Return external value
getExternalValue($column) : mixed
Inherited
inherited_from |
\LudoDBModel::getExternalValue() |
Parameters
$column
Returns
mixed
Returns unique index name
getIndexName($field) : string
Inherited
inherited_from |
\LudoDBModel::getIndexName() |
Parameters
$field
Returns
string
Return values from joined columns.
getJoinColumns() : array
Inherited
inherited_from |
\LudoDBModel::getJoinColumns() |
Returns
array
Return new instance of this LudoDBModel
getNewInstance() : \LudoDBModel
Inherited
inherited_from |
\LudoDBModel::getNewInstance() |
Returns
Validates constructor arguments.
getValidArguments($params) : array
Inherited
inherited_from |
\LudoDBModel::getValidArguments() |
Parameters
$params
Returns
array
Private insert method
insert()
Inherited
inherited_from |
\LudoDBModel::insert() |
Populate model with these data
populateWith(array $data)
Inherited
inherited_from |
\LudoDBModel::populateWith() |
Parameters
$data
array
Set class name for new cache record
setClassName($name)
Update column value of external column
setExternalValue($column, $value)
Inherited
inherited_from |
\LudoDBModel::setExternalValue() |
Parameters
$column
$value
Return values for these keys.
some(array $keys, bool $filtered) : array
Inherited
When $filtered is true, onlye
columns with values(not null) will be returned.
inherited_from |
\LudoDBModel::some() |
Parameters
$keys
array
$filtered
bool
Returns
array
Internal update method
update()
Inherited
inherited_from |
\LudoDBModel::update() |
Properties
$arguments : array
Inherited
inherited_from |
\LudoDBObject::$$arguments |
inherited_from |
\LudoDBModel::$$arguments |
$configParsers : array
Inherited
inherited_from |
\LudoDBObject::$$configParsers |
inherited_from |
\LudoDBModel::$$configParsers |
$data : array
Inherited
inherited_from |
\LudoDBModel::$$data |
$db : \LudoDB
Inherited
inherited_from |
\LudoDBObject::$$db |
inherited_from |
\LudoDBModel::$$db |
$updates : array
Inherited
inherited_from |
\LudoDBModel::$$updates |
$commitDisabled :
Inherited
no saving will be done
for this object.
inherited_from |
\LudoDBModel::$$commitDisabled |
$configParserKey : string
Inherited
inherited_from |
\LudoDBObject::$$configParserKey |
inherited_from |
\LudoDBModel::$$configParserKey |
$externalClasses : array
Inherited
inherited_from |
\LudoDBModel::$$externalClasses |
$populated : bool
Inherited
inherited_from |
\LudoDBModel::$$populated |
$riskyQuery : string
Inherited
inherited_from |
\LudoDBModel::$$riskyQuery |
$sql_handler : \LudoDBSql
Inherited
inherited_from |
\LudoDBObject::$$sql_handler |
inherited_from |
\LudoDBModel::$$sql_handler |