Exemple #1
0
 static function initialize($config = array())
 {
     self::$filed_dir = './' . Core::option('files_name') . '/vars';
     foreach ($config as $key => $value) {
         self::${$key} = $value;
     }
     self::register_type('CMS_Var_Type_Dir', 'CMS_Var_Type_Integer', 'CMS_Var_Type_String', 'CMS_Var_Type_Text', 'CMS_Var_Type_Html', 'CMS_Var_Type_Array', 'CMS_Var_Type_Mail', 'CMS_Var_Type_HtmlP', 'CMS_Var_Type_File');
     CMS_Dumps::dumper('VARS', 'CMS.Dumps.Vars');
     Core::load('DB.SQL');
     DB_SQL::db()->table(DB_SQL::Table('vars')->maps_to('CMS.Var')->serial('id')->columns('id', 'parent_id', 'site', 'component', 'code', 'title', 'value', 'valuesrc', 'vartype', 'parms', 'parmsrc', 'full')->default_sql('select', 'find', 'insert', 'update', 'delete', 'count')->sql('insert_new', DB_SQL::Insert('parent_id', 'site', 'code', 'title', 'full', 'vartype', 'value', 'valuesrc', 'parms', 'parmsrc'))->sql('find_by_code', DB_SQL::Find()->where('code=:code', 'site=:site', 'parent_id=:parent_id', 'component=:component'))->sql('update_parms', DB_SQL::Update()->set('vartype=:vartype,code=:code,title=:title,full=:full')->where('id=:id'))->sql('update_value', DB_SQL::Update()->set('value=:value')->where('id=:id'))->sql('update_value_src', DB_SQL::Update()->set('value=:value,valuesrc=:valuesrc')->where('id=:id'))->sql('update_full_value', DB_SQL::Update()->set('value=:value,valuesrc=:valuesrc,parms=:parms,parmsrc=:parmsrc')->where('id=:id'))->sql('get_code', DB_SQL::Count('code')->where('id=:id'))->sql('delete_component', DB_SQL::Delete()->where('component=:component'))->sql('select_code', DB_SQL::Select()->columns('parent_id,code')->where('id=:id'))->sql('select_childs', DB_SQL::Select()->columns('id', 'code')->where('parent_id=:parent_id'))->sql('select_dir', DB_SQL::Select()->where('parent_id=:parent_id', 'site=:site', 'component=:component')->order_by('IF(vartype="dir",0,1),id'))->sql('select_component', DB_SQL::Select()->where('component=:component')->order_by('parent_id,id'))->sql('select_dir_common', DB_SQL::Select()->where('parent_id=:parent_id', 'site=:site', 'full=0', 'component=:component')->order_by('IF(vartype="dir",0,1),id')));
 }
Exemple #2
0
 public function default_sql()
 {
     $args = Core_Arrays::flatten(func_get_args());
     foreach (count($args) > 0 ? $args : array('find', 'select', 'count', 'insert', 'update', 'delete') as $name) {
         switch ($name) {
             case 'find':
                 $this->isql('find', DB_SQL::Find()->where('id = :id'));
                 break;
             case 'select':
                 $this->isql('select', DB_SQL::Select());
                 break;
             case 'count':
                 $this->isql('count', DB_SQL::Count());
                 break;
             case 'insert':
                 $this->isql('insert', DB_SQL::Insert());
             case 'update':
                 $this->isql('update', DB_SQL::Update()->where('id = :id'));
                 break;
             case 'delete':
                 $this->isql('delete', DB_SQL::Delete()->where('id = :id'));
                 break;
         }
     }
     return $this;
 }