This class sets, gets and deletes a single value stored in a database.
The record doesn't need to have an index/ID.
Upon creation of the object, the database (optional), table and column where
the value is stored, are defined.
Also the column name and it's value to select the value have to be defined.
category |
Database |
package |
Formaid |
author |
Dieter Adriaenssens |
copyright |
2006-2013 Dieter Adriaenssens |
license |
GPL |
link |
http://formaid.sourceforge.net/ |
todo |
create GeneralDbValue class that can get/store multiple values from
the same record, or use multiple statements in the where clause |
todo |
create class that handles data in a record with an ID (relational Db) |
Methods
Constructor, defines simple database value class
__construct(string $valueColumn, string $selectColumn, string $table, string $selectValue, string $database, bool $clearDbValue) : void
Defines current value and default value.
Parameters
$valueColumn
string
Column name of value
$selectColumn
string
Column to select on
$table
string
Table with value
$selectValue
string
Value to select on (optional, default : null)
$database
string
Database with value (optional, default : null)
$clearDbValue
bool
if true clear value instead of removing the record
(optional, default : false)
Deletes a value stored in a database.
deleteDbValue(bool $clearDbValue) : bool
If $clearValue is true, the value in the database will be set to '',
otherwise, the record will be removed.
Parameters
$clearDbValue
bool
if true clear value instead of removing the record
Returns
bool
true if deleting value was succesful
Disables trimming whitespace of object name
disableTrimName() : void
Inherited
inherited_from |
\Formaid_Object::disableTrimName() |
inherited_from |
\Formaid_Property::disableTrimName() |
Display object
display() : void
Inherited
The name of the object is printed to stdout.
inherited_from |
\Formaid_Object::display() |
inherited_from |
\Formaid_Property::display() |
Enables trimming whitespace of object name
enableTrimName() : void
Inherited
inherited_from |
\Formaid_Object::enableTrimName() |
inherited_from |
\Formaid_Property::enableTrimName() |
Gets a value stored in a database.
getDbValue() : mixed
Returns
mixed
value from database
Get display seperator
getDisplaySeparator() : string
Inherited
inherited_from |
\Formaid_Property::getDisplaySeparator() |
Returns
string
String separating columns
return Display string
getDisplayString(bool $withValue, bool $discardEmptyValue) : string
Inherited
access |
public |
inherited_from |
\Formaid_Property::getDisplayString() |
Parameters
$withValue
bool
append value to column
(optional, default : true)
$discardEmptyValue
bool
discard columns with empty values
(optional, default : false)
Returns
string
formatted object string
Returns name of the object
getName() : string
Inherited
inherited_from |
\Formaid_Object::getName() |
inherited_from |
\Formaid_Property::getName() |
Returns
string
object name
Returns current value
getValue() : string
Inherited
inherited_from |
\Formaid_Property::getValue() |
Returns
string
current value
Checks if current value is empty
isEmpty() : bool
Inherited
inherited_from |
\Formaid_Property::isEmpty() |
Returns
bool
true if empty
Checks if object name is empty
isNameEmpty() : bool
Inherited
inherited_from |
\Formaid_Object::isNameEmpty() |
inherited_from |
\Formaid_Property::isNameEmpty() |
Returns
bool
true if empty
Resets current value
resetValue() : void
Inherited
inherited_from |
\Formaid_Property::resetValue() |
Stores a value in a database.
setDbValue(mixed $value) : bool
If the value does not exist in the database, add it.
If the new value is the same as the one in the database, do nothing.
If a value already exists in the database, update the value.
Parameters
Returns
bool
true if setting value was succesful
Sets current value to default
setDefault(string $value) : void
Inherited
When the parameter is set,
the default value is changed to the new default value.
Then the current value is set to the (new) default value.
inherited_from |
\Formaid_Property::setDefault() |
Parameters
$value
string
New default value
Sets new name for the object
setName(string $new_name) : void
Inherited
inherited_from |
\Formaid_Object::setName() |
inherited_from |
\Formaid_Property::setName() |
Parameters
Sets current value to new value
setValue(string $new_value) : void
Inherited
inherited_from |
\Formaid_Property::setValue() |
Parameters
$new_value
string
New value
Show object
show() : void
Inherited
The name of the object is printed to stdout.
inherited_from |
\Formaid_Object::show() |
inherited_from |
\Formaid_Property::show() |
Returns name formatted for displaying
getDisplayName() : string
Inherited
inherited_from |
\Formaid_Object::getDisplayName() |
inherited_from |
\Formaid_Property::getDisplayName() |
Returns
string
formatted object name
Returns value formatted for displaying
getDisplayValue() : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::getDisplayValue() |
Returns
string
formatted object value
Creates WHERE clause
getWhereClause() : string
WHERE clause selecting for selectColumn = selectValue
Returns
string
WHERE clause
Deletes a value stored in a database using a DELETE statement.
_deleteDbValue() : \handle
Returns
\handle
query result
Inserts a value in a database using an INSERT statement.
_insertDbValue(mixed $value) : \handle
Parameters
Returns
\handle
query result
Gets a value from a database using a SELECT statement.
_selectDbValue() : string
Returns
string
value from database
Updates a value in a database using an UPDATE statement.
_updateDbValue(mixed $value) : \handle
Parameters
Returns
\handle
query result
Properties
$current_value : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::$$current_value |
$default_value : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::$$default_value |
$displaySeparator : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::$$displaySeparator |
$encoding : string
Inherited
access |
protected |
inherited_from |
\Formaid_Object::$$encoding |
inherited_from |
\Formaid_Property::$$encoding |
$name : string
Inherited
access |
protected |
inherited_from |
\Formaid_Object::$$name |
inherited_from |
\Formaid_Property::$$name |
$_dbConn
access |
private |
type |
object |
$_trimName : bool
Inherited
access |
private |
inherited_from |
\Formaid_Object::$$_trimName |
inherited_from |
\Formaid_Property::$$_trimName |