Class db_entity

db_entity
Direct Known Subclasses:
db_images

public class db_entity

Abstract class for an entity in DB.
Used to simplify SELECT SQL queries and rendering of the results.

Note: This is Article System specific class. It uses global $db object.


Constructor Summary
db_entity(var $name)
          Sets up the db_entity table name.
 
Method Summary
 integer delete(var $where)
          Executes a DB DELETE query.
 unknown error_report()
          Prints formatted error message.
 array get_assoc(var $ckey, var $cval, var $assoc, var $where)
          Returns an associative array based on two DB entity columns.
 string get_error()
          Returns text of the last error.
 string get_name()
          Return name of this entity
 array get_one(var $what, var $where)
          Executes a DB SELECT query as get, but returns just the first value.
 array get(var $what, var $where)
          Executes a DB SELECT query.
Note: this uses abstract_db::get_result_array, so the result array can be either numeric, associative or both.
 unknown select_box(var $name, var $cval, var $ctext, var $selected_value, var $begin_options, var $end_options, var $attributes)
          A HTML form select box renderer.
Creates a select box based on the results of previous DB query.
 

Constructor Detail

db_entity

public db_entity(var $name)
Sets up the db_entity table name.
Parameters:
$name - Name of the table in DB describing the entity, string.
See Also:
abstract_db
Method Detail

get

public array get(var $what,
                 var $where)
Executes a DB SELECT query.
Note: this uses abstract_db::get_result_array, so the result array can be either numeric, associative or both.
Parameters:
$what - string The text between 'SELECT' and 'FROM'. Column names or "*".
$where - string Optional WHERE/ORDER clause.
$where - Default Value: ""

get_one

public array get_one(var $what,
                     var $where)
Executes a DB SELECT query as get, but returns just the first value.
Parameters:
$what - string The text between 'SELECT' and 'FROM'. Column names or "*".
$where - string Optional WHERE/ORDER clause.
$where - Default Value: ""

get_assoc

public array get_assoc(var $ckey,
                       var $cval,
                       var $assoc,
                       var $where)
Returns an associative array based on two DB entity columns.
Parameters:
$ckey - string First column name. Used as keys to associative array.
$cval - string Second column name. Used as values to associative array.
$assoc - array An array to put values to.
$where - string Optional WHERE/ORDER clause.
$assoc - is passed by reference
$where - Default Value: ""

delete

public integer delete(var $where)
Executes a DB DELETE query. Returns number of deleted rows.
Parameters:
$where - string Compulsory WHERE clause.

get_error

public string get_error()
Returns text of the last error.

error_report

public unknown error_report()
Prints formatted error message. Applications should call this function at a 'placeholder' that displays an error message if error occurs.

get_name

public string get_name()
Return name of this entity

select_box

public unknown select_box(var $name,
                          var $cval,
                          var $ctext,
                          var $selected_value,
                          var $begin_options,
                          var $end_options,
                          var $attributes)
A HTML form select box renderer.
Creates a select box based on the results of previous DB query.
Parameters:
$name - Name of the select form item.
$cval - Name of column or index to the query result, to be used as option's value="".
$ctext - Name of column or index to the query result, to be used as option's label (text to display).
$selected_value - TODO: ..
$begin_options - Default Value: ""
$end_options - Default Value: ""
$attributes - Default Value: ""
Returns:
void