3 * Table Definition for core company
5 require_once 'DB/DataObject.php';
7 class Pman_Core_DataObjects_Core_enum extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'core_enum'; // table name
13 public $id; // int(11) not_null primary_key auto_increment
14 public $etype; // string(32) not_null
15 public $name; // string(255) not_null
16 public $active; // int(2) not_null
17 public $seqid; // int(11) not_null multiple_key
18 public $seqmax; // int(11) not_null multiple_key
21 /* the code above is auto generated do not remove the tag below */
23 function applyFilters($q, $au)
26 //DB_DataObject::debugLevel(1);
27 if (!empty($q['query']['empty_etype'])) {
28 $this->whereAdd("etype = ''");
32 function onUpdate($old, $req)
34 $x = $this->factory($this->tableName());
35 $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
36 if ($old->etype != $this->etype) {
37 $x->query("SELECT core_enum_seqmax_update('". $this->escape($old->etype) ."')");
41 function beforeInsert($req, $roo)
43 $tn = $this->tableName();
44 $x = $this->factory($tn);
46 if(empty($req['etype'])){
47 if($x->get('name', $req['name'])){
48 $roo->jerr('name is exsiting');
51 $x->whereAdd("$tn.etype = {$req['etype']} AND $tn.name = {$req['name']}");
54 $roo->jerr('is exsiting');
59 // if($x->get('etype', $req['etype']) && !empty($req['etype'])){
60 // $roo->jerr('etype is exsiting');
62 // if($x->get('name', $req['name'])){
63 // $roo->jerr('name is exsiting');
66 function onInsert($req)
68 $x = $this->factory($this->tableName());
69 $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
73 function lookup($etype,$name) {
74 $ce = DB_DataObject::Factory('core_enum');
77 if ($ce->find(true)) {
84 function lookupObject($etype,$name, $create= false)
87 static $cache = array();
88 $key = "$etype:$name";
89 if (isset($cache[$key]) ) {
92 $ce = DB_DataObject::Factory('core_enum');
95 if ($ce->find(true)) {