Source for file tangra_module_dbc.class.php
Documentation is available at tangra_module_dbc.class.php
* Contains class Tangra_Module_DBC
* @subpackage modules_manager
require_once(TANGRA_MAIN_DIR. 'interfaces/i_db_storable.class.php');
require_once('tangra_module.class.php');
* @subpackage modules_manager
* @param DB_Connection $dbc
* @return integer On success returns module ID, on failure - false
public function save(DB_Connection $dbc) {
* @param DB_Connection $dbc
* @return integer On success returns module ID, on failure - false
public function load_by_id(DB_Connection $dbc, $id) {
$rez = $dbc->execute($sql);
$rez_obj = $rez->fetch_object();
* @param DB_Connection $dbc
* @return integer On success returns module ID, on failure - false
protected function insert(DB_Connection $dbc) {
$id = $dbc->generate_id('tmods_seq');
$sql = "insert into tmods (id, ".
throw new TE_Exception('ID not generated - tmods_seq');
* Updates module DB record
* @param DB_Connection $dbc
* @return integer On success returns module ID, on failure - false
protected function update(DB_Connection $dbc) {
$sql = "update tmods set ".
"description = '$description', ".
"maintainer = '$maintainer', ".
* @return string SQL statement
$sql = "select id, hid from tmods order by hid asc";
* Gets count SQL for grid
* @return string SQL statement
$sql = "select count(id) as total_rows from tmods";
* Checks if HID is unique
* @param DB_Connection $dbc
* @param string $hid HID to check if exists
* @param integer $id ID of current category
public static function is_unique_hid(DB_Connection $dbc, $hid, $id = 0) {
$sql = "select id from tmods where hid = '$hid' and id <> $id";
$rez = $dbc->execute($sql);
* Loads options labels map for Form_field_select
* @param DB_Connection $dbc
* @param integer $current_module_id
$sql = "select id, hid from tmods where id <> $current_module_id order by id asc";
$rez = $dbc->execute($sql);
while($rez_obj = $rez->fetch_object()) {
$ret['ol_map'][$rez_obj->ID] = $rez_obj->HID;
* @param DB_Connection $dbc
* @return integer On success returns module ID, on failure - false
public function load_by_hid(DB_Connection $dbc, $hid) {
$sql = "select id from tmods where hid = '$hid'";
$rez = $dbc->execute($sql);
$rez_obj = $rez->fetch_object();
* @param DB_Connection $dbc
* @return array Array of Tangra_Module_DBC objects
public static function load_all(DB_Connection $dbc) {
$sql = "select id from tmods";
$rez = $dbc->execute($sql);
while ($rez_obj = $rez->fetch_object()) {
$tmp->load_by_id($dbc, $rez_obj->ID);
* Loads all HIDs as array
* @param DB_Connection $dbc
$sql = "select hid from tmods";
$rez = $dbc->execute($sql);
while ($rez_obj = $rez->fetch_object()) {
$ret[$rez_obj->HID] = false;
* @param DB_Connection $dbc
public static function delete(DB_Connection $dbc, $id) {
$sql = "delete from tmods where id = $id";
|