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


PHP ezcDbSchema::createNewIndexField方法代码示例

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


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

示例1: parseIndex

 /**
  * Extracts information about an index from the XML element $index
  * 
  * @param SimpleXMLElement $index
  *
  * @return ezcDbSchemaIndex or an inherited class
  */
 private function parseIndex(SimpleXMLElement $index)
 {
     $indexFields = array();
     foreach ($index->field as $indexField) {
         $indexFieldName = (string) $indexField->name;
         $indexFields[$indexFieldName] = ezcDbSchema::createNewIndexField(isset($indexField->sorting) ? (string) $indexField->sorting : null);
     }
     return ezcDbSchema::createNewIndex($indexFields, isset($index->primary) ? (string) $index->primary : false, isset($index->unique) ? (string) $index->unique : false);
 }
开发者ID:Adeelgill,项目名称:livehelperchat,代码行数:16,代码来源:reader.php

示例2: fetchTableIndexes

 /**
  * Loops over all the indexes in the table $table and extracts information.
  *
  * This method extracts information about the table $tableName's indexes
  * from the database and returns this schema as an array of
  * ezcDbSchemaIndex objects. The key in the array is the index' name.
  *
  * @param  string $tableName
  * @return array(string=>ezcDbSchemaIndex)
  */
 protected function fetchTableIndexes($tableName)
 {
     $indexBuffer = array();
     $resultArray = $this->db->query("SHOW INDEX FROM `{$tableName}`");
     foreach ($resultArray as $row) {
         $keyName = $row['key_name'];
         if ($keyName == 'PRIMARY') {
             $keyName = 'primary';
         }
         $indexBuffer[$keyName]['primary'] = false;
         $indexBuffer[$keyName]['unique'] = true;
         if ($keyName == 'primary') {
             $indexBuffer[$keyName]['primary'] = true;
             $indexBuffer[$keyName]['unique'] = true;
         } else {
             $indexBuffer[$keyName]['unique'] = $row['non_unique'] ? false : true;
         }
         $indexBuffer[$keyName]['fields'][$row['column_name']] = ezcDbSchema::createNewIndexField();
         //            if ( $row['sub_part'] )
         //            {
         //                $indexBuffer[$keyName]['options']['limitations'][$row['column_name']] = $row['sub_part'];
         //            }
     }
     $indexes = array();
     foreach ($indexBuffer as $indexName => $indexInfo) {
         $indexes[$indexName] = ezcDbSchema::createNewIndex($indexInfo['fields'], $indexInfo['primary'], $indexInfo['unique']);
     }
     return $indexes;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:39,代码来源:reader.php

示例3: fetchTableIndexes

 /**
  * Loops over all the indexes in the table $table and extracts information.
  *
  * This method extracts information about the table $tableName's indexes
  * from the database and returns this schema as an array of
  * ezcDbSchemaIndex objects. The key in the array is the index' name.
  *
  * @param  string $tableName
  * @return array(string=>ezcDbSchemaIndex)
  */
 protected function fetchTableIndexes($tableName)
 {
     $indexBuffer = array();
     $indexesArray = array();
     // fetching index info from Oracle
     $getIndexSQL = "SELECT uind.index_name AS name, " . "       uind.index_type AS type, " . "       decode( uind.uniqueness, 'NONUNIQUE', 0, 'UNIQUE', 1 ) AS is_unique, " . "       uind_col.column_name AS column_name, " . "       uind_col.column_position AS column_pos " . "FROM user_indexes uind, user_ind_columns uind_col " . "WHERE uind.index_name = uind_col.index_name AND uind_col.table_name = '{$tableName}'";
     $indexesArray = $this->db->query($getIndexSQL)->fetchAll();
     $primaryFound = false;
     // getting columns to which each index related.
     foreach ($indexesArray as $row) {
         $keyName = $row['name'];
         if ($keyName == $tableName . '_pkey') {
             $keyName = 'primary';
             $indexBuffer[$keyName]['primary'] = true;
             $indexBuffer[$keyName]['unique'] = true;
             $primaryFound = true;
         } else {
             $indexBuffer[$keyName]['primary'] = false;
             $indexBuffer[$keyName]['unique'] = $row['is_unique'] == 1 ? true : false;
         }
         $indexBuffer[$keyName]['fields'][$row['column_name']] = ezcDbSchema::createNewIndexField();
     }
     $indexes = array();
     foreach ($indexBuffer as $indexName => $indexInfo) {
         $indexes[$indexName] = ezcDbSchema::createNewIndex($indexInfo['fields'], $indexInfo['primary'], $indexInfo['unique']);
     }
     return $indexes;
 }
开发者ID:Adeelgill,项目名称:livehelperchat,代码行数:38,代码来源:reader.php

示例4: fetchTableIndexes

 /**
  * Loops over all the indexes in the table $table and extracts information.
  *
  * This method extracts information about the table $tableName's indexes
  * from the database and returns this schema as an array of
  * ezcDbSchemaIndex objects. The key in the array is the index' name.
  *
  * @param  string $tableName
  * @return array(string=>ezcDbSchemaIndex)
  */
 protected function fetchTableIndexes($tableName)
 {
     $indexBuffer = array();
     $resultArray = array();
     // fetching index info from PostgreSQL
     $getIndexSQL = "SELECT relname, pg_index.indisunique, pg_index.indisprimary, \n                               pg_index.indkey, pg_index.indrelid \n                         FROM pg_class, pg_index\n                         WHERE oid IN ( \n                                SELECT indexrelid \n                                FROM pg_index, pg_class \n                                WHERE pg_class.relname='{$tableName}' AND pg_class.oid=pg_index.indrelid \n                             ) \n                      AND pg_index.indexrelid = oid";
     $indexesArray = $this->db->query($getIndexSQL)->fetchAll();
     // getting columns to which each index related.
     foreach ($indexesArray as $row) {
         $myIndex[] = $row['relname'];
         $colNumbers = explode(' ', $row['indkey']);
         $colNumbersSQL = 'IN (' . join(' ,', $colNumbers) . ' )';
         $indexColumns = $this->db->query("SELECT attname \n                                               FROM pg_attribute \n                                               WHERE attrelid={$row['indrelid']} \n                                                     AND attnum {$colNumbersSQL};");
         foreach ($indexColumns as $colRow) {
             $resultArray[] = array('key_name' => $row['relname'], 'column_name' => $colRow['attname'], 'non_unique' => !$row['indisunique'], 'primary' => !$row['indisprimary']);
             $indexColumnNames[] = $colRow['attname'];
         }
     }
     foreach ($resultArray as $row) {
         $keyName = $row['key_name'];
         if (substr($keyName, -5) == '_pkey') {
             $keyName = 'primary';
         }
         $indexBuffer[$keyName]['primary'] = false;
         $indexBuffer[$keyName]['unique'] = true;
         if ($keyName == 'primary') {
             $indexBuffer[$keyName]['primary'] = true;
             $indexBuffer[$keyName]['unique'] = true;
         } else {
             $indexBuffer[$keyName]['unique'] = $row['non_unique'] ? false : true;
         }
         $indexBuffer[$keyName]['fields'][$row['column_name']] = ezcDbSchema::createNewIndexField();
     }
     $indexes = array();
     foreach ($indexBuffer as $indexName => $indexInfo) {
         $indexes[$indexName] = ezcDbSchema::createNewIndex($indexInfo['fields'], $indexInfo['primary'], $indexInfo['unique']);
     }
     return $indexes;
 }
开发者ID:valentinbora,项目名称:joobsbox-php,代码行数:49,代码来源:reader.php


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