当前位置: 首页>>代码示例>>PHP>>正文


PHP Fx::db方法代码示例

本文整理汇总了PHP中Floxim\Floxim\System\Fx::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Fx::db方法的具体用法?PHP Fx::db怎么用?PHP Fx::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Floxim\Floxim\System\Fx的用法示例。


在下文中一共展示了Fx::db方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: up

 protected function up()
 {
     $new_fields = array(array('keyword' => 'is_published', 'name_en' => 'Is published?', 'name_ru' => '', 'type' => '5', 'not_null' => '0', 'priority' => '267', 'searchable' => '0', 'default' => '1', 'type_of_edit' => '1', 'checked' => '1', 'form_tab' => '0'), array('keyword' => 'is_branch_published', 'name_en' => 'Is branch published?', 'name_ru' => '', 'type' => '5', 'not_null' => '0', 'priority' => '268', 'searchable' => '0', 'default' => '1', 'type_of_edit' => '3', 'checked' => '1', 'form_tab' => '0'));
     $content_id = fx::data('component', 'content')->get('id');
     foreach ($new_fields as $field_props) {
         $field_props['component_id'] = $content_id;
         $field = fx::data('field')->create($field_props);
         $field->save();
         fx::log('add field', $field);
     }
     fx::data('component')->dropStoredStaticCache();
     fx::db()->query('update {{floxim_main_content}} set is_published = 1, is_branch_published = 1');
     fx::cache('meta')->delete('schema');
 }
开发者ID:floxim,项目名称:floxim,代码行数:14,代码来源:m20141208_084116_is_published_field.php

示例2: contentExists

 public function contentExists()
 {
     static $content_by_type = null;
     if (is_null($content_by_type)) {
         $res = fx::db()->getResults('select `type`, count(*) as cnt ' . 'from {{floxim_main_content}} ' . 'where site_id = "' . fx::env('site_id') . '" ' . 'group by `type`');
         $content_by_type = fx::collection($res)->getValues('cnt', 'type');
     }
     $com = $this->getComponent();
     if (isset($content_by_type[$com['keyword']])) {
         return true;
     }
     foreach ($com->getAllChildren() as $child) {
         if (isset($content_by_type[$child['keyword']])) {
             return true;
         }
     }
     return false;
 }
开发者ID:floxim,项目名称:module-main,代码行数:18,代码来源:Finder.php

示例3: beforeInsert

 protected function beforeInsert()
 {
     $entities = $this->getMultilangEntities();
     fx::log('ess', $entities);
     foreach ($entities as $e) {
         $fields = fx::data($e)->getMultiLangFields();
         fx::log('fld', $e, $fields);
         if (count($fields) > 0) {
             $q = "ALTER TABLE `{{" . $e . "}}` ";
             $parts = array();
             foreach ($fields as $f) {
                 $parts[] = "ADD COLUMN `" . $f . "_" . $this['lang_code'] . "` VARCHAR(255) ";
             }
             $q .= join(", ", $parts);
             fx::log('qr', $q);
             fx::db()->query($q);
         }
     }
 }
开发者ID:floxim,项目名称:floxim,代码行数:19,代码来源:Entity.php

示例4: all

 /**
  * A list of all components
  */
 public function all()
 {
     $entity = $this->entity_type;
     $finder = fx::data($entity);
     $tree = $finder->getTree();
     $field = array('type' => 'list', 'filter' => true);
     $field['labels'] = array('name' => fx::alang('Name', 'system'), 'keyword' => fx::alang('Keyword'), 'count' => fx::alang('Count', 'system'), 'buttons' => array('type' => 'buttons'));
     $field['values'] = array();
     $field['entity'] = $entity;
     $append_coms = function ($coll, $level) use(&$field, &$append_coms) {
         foreach ($coll as $v) {
             $submenu = Component::getComponentSubmenu($v);
             $submenu_first = current($submenu);
             try {
                 $items_count = fx::db()->getCol("SELECT count(*) from  {{" . $v->getContentTable() . "}}");
             } catch (\Exception $e) {
                 $items_count = 0;
             }
             $r = array('id' => $v['id'], 'keyword' => $v['keyword'], 'count' => $items_count, 'name' => array('name' => $v['name'], 'url' => $submenu_first['url'], 'level' => $level));
             $r['buttons'] = array();
             foreach ($submenu as $submenu_item_key => $submenu_item) {
                 if (!$submenu_item['parent']) {
                     // && $submenu_item_key != 'fields') {
                     $r['buttons'][] = array('type' => 'button', 'label' => $submenu_item['title'], 'url' => $submenu_item['url']);
                 }
             }
             $field['values'][] = $r;
             if (isset($v['children']) && $v['children']) {
                 $append_coms($v['children'], $level + 1);
             }
         }
     };
     $append_coms($tree, 0);
     $fields[] = $field;
     $this->response->addButtons(array(array('key' => "add", 'title' => fx::alang('Add new ' . $entity, 'system'), 'url' => '#admin.' . $entity . '.add'), "delete"));
     $result = array('fields' => $fields);
     $this->response->breadcrumb->addItem(self::entityTypes($entity), '#admin.' . $entity . '.all');
     $this->response->submenu->setMenu($entity);
     return $result;
 }
开发者ID:floxim,项目名称:floxim,代码行数:43,代码来源:Component.php

示例5: deleteContentTable

 protected function deleteContentTable()
 {
     try {
         $contents = fx::data($this['keyword'])->all();
         foreach ($contents as $content) {
             $content->delete();
         }
     } catch (\Exception $e) {
         fx::log('Delete content error:', $e->getMessage());
     }
     $sql = "DROP TABLE `{{" . $this->getContentTable() . "}}`";
     fx::db()->query($sql);
 }
开发者ID:floxim,项目名称:floxim,代码行数:13,代码来源:Entity.php

示例6: handleMove

 public function handleMove()
 {
     $rel_item_id = null;
     if (isset($this['__move_before'])) {
         $rel_item_id = $this['__move_before'];
         $rel_dir = 'before';
     } elseif (isset($this['__move_after'])) {
         $rel_item_id = $this['__move_after'];
         $rel_dir = 'after';
     }
     if (!$rel_item_id) {
         return;
     }
     $rel_item = fx::content($rel_item_id);
     if (!$rel_item) {
         return;
     }
     $rel_priority = fx::db()->getVar(array('select priority from {{floxim_main_content}} where id = %d', $rel_item_id));
     //fx::debug($rel_priority, $rel_item_id);
     if ($rel_priority === false) {
         return;
     }
     // 1 2 3 |4| 5 6 7 (8) 9 10
     $old_priority = $this['priority'];
     $this['priority'] = $rel_dir == 'before' ? $rel_priority : $rel_priority + 1;
     $q_params = array();
     $q = 'update {{floxim_main_content}} ' . 'set priority = priority + 1 ' . 'where ';
     if ($this['parent_id']) {
         $q .= 'parent_id = %d and ';
         $q_params[] = $this['parent_id'];
     }
     $q .= 'infoblock_id = %d ' . 'and priority >= %d ' . 'and id != %d';
     $q_params[] = $this['infoblock_id'];
     $q_params[] = $this['priority'];
     $q_params[] = $this['id'];
     if ($old_priority !== null) {
         $q .= ' and priority < %d';
         $q_params[] = $old_priority;
     }
     array_unshift($q_params, $q);
     fx::db()->query($q_params);
 }
开发者ID:floxim,项目名称:module-main,代码行数:42,代码来源:Entity.php

示例7: setStatement

 protected function setStatement($data)
 {
     $res = array();
     $chain = fx::component($this->component_id)->getChain();
     foreach ($chain as $level_component) {
         $table_res = array();
         $fields = $level_component->fields();
         $field_keywords = $fields->getValues('keyword');
         // while the underlying field content manually prescription
         if ($level_component['keyword'] == 'floxim.main.content') {
             $field_keywords = array_merge($field_keywords, array('priority', 'last_updated', 'type', 'infoblock_id', 'materialized_path', 'level'));
         }
         $table_name = $level_component->getContentTable();
         $table_cols = $this->getColumns($table_name);
         foreach ($field_keywords as $field_keyword) {
             if (!in_array($field_keyword, $table_cols)) {
                 continue;
             }
             $field = $fields->findOne('keyword', $field_keyword);
             // put only if the sql type of the field is not false (e.g. multilink)
             if ($field && !$field->getSqlType()) {
                 continue;
             }
             //if (isset($data[$field_keyword]) ) {
             if (array_key_exists($field_keyword, $data)) {
                 $field_val = $data[$field_keyword];
                 $sql_val = is_null($field_val) ? 'NULL' : "'" . fx::db()->escape($field_val) . "'";
                 $table_res['`' . fx::db()->escape($field_keyword) . '`'] = $sql_val;
             }
         }
         if (count($table_res) > 0) {
             $res[$table_name] = $table_res;
         }
     }
     return $res;
 }
开发者ID:floxim,项目名称:floxim,代码行数:36,代码来源:Finder.php

示例8: countLostContent

 public function countLostContent()
 {
     if (is_null(self::$lost_content_stats)) {
         self::$lost_content_stats = array();
         $site_id = fx::env('site_id');
         if (!$site_id) {
             return 0;
         }
         $lost = fx::db()->getResults('select count(*) as cnt, `type` 
             from {{floxim_main_content}} as c
             left join {{infoblock}} as ib on c.infoblock_id = ib.id
             where ib.id IS NULL and c.site_id = ' . $site_id . ' 
             group by c.type');
         foreach ($lost as $entry) {
             self::$lost_content_stats[$entry['type']] = $entry['cnt'];
         }
     }
     $c_type = $this->getComponent()->get('keyword');
     return isset(self::$lost_content_stats[$c_type]) ? self::$lost_content_stats[$c_type] : 0;
 }
开发者ID:floxim,项目名称:module-main,代码行数:20,代码来源:Controller.php

示例9: move

 public function move($input)
 {
     if (!isset($input['visual_id']) || !isset($input['area'])) {
         return;
     }
     $vis = fx::data('infoblock_visual', $input['visual_id']);
     if (!$vis) {
         return;
     }
     $infoblock = fx::data('infoblock', $input['infoblock_id']);
     if (!$infoblock) {
         return;
     }
     // move from region to region
     // need to rearrange the blocks from the old area
     // until very stupidly, in order
     if ($vis['area'] != $input['area']) {
         $source_vis = $this->getAreaVisual($vis['area'], $vis['layout_id'], $infoblock['site_id']);
         $cpos = 1;
         foreach ($source_vis as $csv) {
             if ($csv['id'] == $vis['id']) {
                 continue;
             }
             fx::db()->query("UPDATE {{infoblock_visual}}\n                    SET priority = '" . $cpos . "'\n                    WHERE id = '" . $csv['id'] . "'");
             $cpos++;
         }
     }
     $target_vis = $this->getAreaVisual($input['area'], $vis['layout_id'], $infoblock['site_id']);
     $next_visual_id = isset($input['next_visual_id']) ? $input['next_visual_id'] : null;
     $cpos = 1;
     $new_priority = null;
     foreach ($target_vis as $ctv) {
         if ($ctv['id'] == $vis['id']) {
             continue;
         }
         if ($ctv['id'] == $next_visual_id) {
             $new_priority = $cpos;
             $cpos++;
         }
         if ($ctv['priority'] != $cpos) {
             fx::db()->query("UPDATE {{infoblock_visual}}\n                    SET priority = '" . $cpos . "'\n                    WHERE id = '" . $ctv['id'] . "'");
         }
         $cpos++;
     }
     if (!$new_priority) {
         $new_priority = $cpos;
     }
     fx::db()->query("UPDATE {{infoblock_visual}}\n            SET priority = '" . $new_priority . "', area = '" . $input['area'] . "'\n            WHERE id = '" . $vis['id'] . "'");
     return array('status' => 'ok');
 }
开发者ID:piarsonforked,项目名称:floxim,代码行数:50,代码来源:Infoblock.php

示例10: afterDelete

 protected function afterDelete()
 {
     if ($this['component_id']) {
         if (self::getSqlTypeByType($this->data['type'])) {
             try {
                 fx::db()->query("ALTER TABLE `{{" . $this->getTable() . "}}` DROP COLUMN `" . $this['keyword'] . "`");
             } catch (\Exception $e) {
                 fx::log('Drop field exception', $e->getMessage());
             }
         }
     }
     parent::afterDelete();
 }
开发者ID:floxim,项目名称:floxim,代码行数:13,代码来源:Entity.php

示例11: down

 protected function down()
 {
     fx::db()->query('ALTER TABLE `{{lang}}` DROP `declension`');
     fx::db()->query('ALTER TABLE `{{component}}` DROP `declension_ru`');
     fx::db()->query('ALTER TABLE `{{component}}` DROP `declension_en`');
 }
开发者ID:floxim,项目名称:floxim,代码行数:6,代码来源:m20150901_145806_declensions.php

示例12: dropOldSessions

 public function dropOldSessions()
 {
     $ttl = (int) fx::config('auth.remember_ttl');
     fx::db()->query('delete from {{session}} ' . 'where ' . 'user_id is not null ' . 'and last_activity_time + ' . $ttl . ' < ' . time());
 }
开发者ID:floxim,项目名称:floxim,代码行数:5,代码来源:Finder.php


注:本文中的Floxim\Floxim\System\Fx::db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。