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