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


PHP FArrayHelper::filter方法代码示例

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


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

示例1: addIndex

 /**
  * Add an index to the table
  *
  * @param   string  $field   field name
  * @param   string  $prefix  index name prefix (allows you to differentiate between indexes created in
  * different parts of fabrik)
  * @param   string  $type    index type
  * @param   string  $size    index length
  *
  * @return void
  */
 public function addIndex($field, $prefix = '', $type = 'INDEX', $size = '')
 {
     if (is_numeric($field)) {
         $el = $this->getFormModel()->getElement($field, true);
         $field = $el->getFullName(true, false);
     }
     /* $$$ hugh - @TODO $field is in 'table.element' format but $indexes
      * has Column_name as just 'element' ... so we're always rebuilding indexes!
      * I'm in the middle of fixing something else, must come back and fix this!!
      * OK, moved these two lines from below to here
      */
     $field = str_replace('_raw', '', $field);
     // $$$ rob 29/03/2011 ensure its in tablename___elementname format
     $field = str_replace('.', '___', $field);
     // $$$ rob 28/02/2011 if index in joined table we need to use that the make the key on
     if (!strstr($field, '___')) {
         $table = $this->getTable()->db_table_name;
     } else {
         $fieldParts = explode('___', $field);
         $table = array_shift($fieldParts);
     }
     $field = FabrikString::shortColName($field);
     $indexes = $this->getIndexes($table);
     FArrayHelper::filter($indexes, 'Column_name', $field);
     if (!empty($indexes)) {
         // An index already exists on that column name no need to add
         return;
     }
     $db = $this->getDb();
     if ($field == '') {
         return;
     }
     if ($size != '') {
         $size = '( ' . $size . ' )';
     }
     $this->dropIndex($field, $prefix, $type, $table);
     $query = ' ALTER TABLE ' . $db->qn($table) . ' ADD INDEX ' . $db->qn("fb_{$prefix}_{$field}_{$type}") . ' (' . $db->qn($field) . ' ' . $size . ')';
     $db->setQuery($query);
     try {
         $db->execute();
     } catch (RuntimeException $e) {
         // Try to suppress error
         $this->setError($e->getMessage());
     }
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:56,代码来源:list.php

示例2: addIndex

 /**
  * add an index to the table
  * @param string field name
  * @param stirng index name prefix (allows you to differentiate between indexes created in
  * different parts of fabrik)
  * @param string index type
  * @param int index length
  */
 public function addIndex($field, $prefix = '', $type = 'INDEX', $size = '')
 {
     $indexes =& $this->getIndexes();
     if (is_numeric($field)) {
         $el = $this->getFormModel()->getElement($field, true);
         $field = $el->getFullName(false, true, false);
     }
     // $$$ hugh - @TODO $field is in 'table.element' format but $indexes
     // has Column_name as just 'element' ... so we're always rebuilding indexes!
     // I'm in the middle of fixing something else, must come back and fix this!!
     // OK, moved these two lines from below to here
     $field = str_replace('_raw', '', $field);
     // $$$ rob 29/03/2011 ensure its in tablename___elementname format
     $field = str_replace('.', '___', $field);
     // $$$ rob 28/02/2011 if index in joined table we need to use that the make the key on
     if (!strstr($field, '___')) {
         $table = $this->getTable()->db_table_name;
     } else {
         $table = array_shift(explode('___', $field));
     }
     $field = FabrikString::shortColName($field);
     FArrayHelper::filter($indexes, 'Column_name', $field);
     if (!empty($indexes)) {
         // an index already exists on that column name no need to add
         return;
     }
     $db = $this->getDb();
     if ($field == '') {
         return;
     }
     if ($size != '') {
         $size = "( {$size} )";
     }
     $this->dropIndex($field, $prefix, $type, $table);
     $query = " ALTER TABLE " . $db->nameQuote($table) . " ADD INDEX " . $db->nameQuote("fb_{$prefix}_{$field}_{$type}") . " (" . $db->nameQuote($field) . " {$size})";
     $db->setQuery($query);
     $db->query();
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:46,代码来源:list.php


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