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


PHP MatchaModel::tableId方法代码示例

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


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

示例1: audit

 /**
  * function audit($logModelArray = array(), $methodCall = NULL, $idColumn = 'id', $logTable = 'log', $classCall = NULL)
  * Method to enable the audit log process.
  * This will write a log every time it INSERT, UPDATE, DELETE a record.
  */
 public static function audit($logModelArray = array(), $methodCall = NULL, $idColumn = 'id', $logTable = 'log', $classCall = NULL)
 {
     self::$__audit = true;
     self::$hookTable = $logTable;
     MatchaModel::$tableId = $idColumn;
     if ($classCall == NULL) {
         self::$hookClass = get_called_class();
     } else {
         self::$hookClass = $classCall;
     }
     self::$hookMethod = $methodCall;
     self::defineLogModel($logModelArray);
 }
开发者ID:nagyist,项目名称:tutus,代码行数:18,代码来源:MatchaAudit.php

示例2: __SenchaModel

 /**
  * function SenchaModel($fileModel):
  * This method will create the table and fields if does not exist in the database
  * also this is the brain of the micro ORM.
  *
  * This method needs rework, this method has to be the brain!
  *
  * @param string $fileModel 'App.model.Example'
  * @param bool $force for to read the sencha model file (skip the MatchaMemory)
  * @return bool success
  *
  */
 public static function __SenchaModel($fileModel, $force = false)
 {
     try {
         self::$fileModel = $fileModel;
         // skip this entire routine if freeze option is true
         if (self::$__freeze) {
             self::$__senchaModel = self::__getSenchaModel($fileModel);
             return true;
         }
         self::$__senchaModel = array();
         // check the difference in dates of the Sencha model file and the stored Sencha model on the server memory,
         // if there are equal go ahead and load the model from memory and quit the procedure
         if (!$force && self::__getFileModifyDate($fileModel) == MatchaMemory::__getSenchaModelLastChange($fileModel)) {
             self::$__senchaModel = MatchaMemory::__getModelFromMemory($fileModel);
             return true;
         }
         // get the model of the table from the sencha .js file
         self::$__senchaModel = self::__getSenchaModel($fileModel);
         if (!self::$__senchaModel['fields']) {
             return false;
         }
         // get model fields
         $modelFields = (array) self::$__senchaModel['fields'];
         // Copy the table ID from the idProperty if the idProperty is undefined use "id" instead.
         self::$tableId = isset(self::$__senchaModel['idProperty']) ? self::$__senchaModel['idProperty'] : 'id';
         //id properties
         $tableIdIndex = MatchaUtils::__recursiveArraySearch(self::$tableId, $modelFields);
         self::$tableIdProperties = $modelFields[$tableIdIndex];
         // check if the table property is an array, if not return the array is a table string.
         $table = (string) (is_array(self::$__senchaModel['table']) ? self::$__senchaModel['table']['name'] : self::$__senchaModel['table']);
         // verify the existence of the table if it does not exist create it
         $recordSet = self::$__conn->query("SHOW TABLES LIKE '" . $table . "';");
         if (isset($recordSet)) {
             self::__createTable($table);
         }
         // if id property is not set in sencha model look for propertyId.
         if ($modelFields[$tableIdIndex] === false) {
             unset($modelFields[$tableIdIndex]);
         }
         // unset the fields that will noe be store int the database
         foreach ($modelFields as $key => $field) {
             if (isset($field['store']) && $field['store'] === false || isset($field['persist']) && $field['persist'] === false) {
                 unset($modelFields[$key]);
             }
         }
         // get the table column information and remove the id column
         $tableColumns = self::$__conn->query("SHOW FULL COLUMNS IN " . $table . ";")->fetchAll(PDO::FETCH_ASSOC);
         unset($tableColumns[MatchaUtils::__recursiveArraySearch(self::$tableId, $tableColumns)]);
         $columnsTableNames = array();
         $columnsSenchaNames = array();
         // get all the column names of each model (Sencha and Database-table)
         foreach ($tableColumns as $column) {
             $columnsTableNames[] = $column['Field'];
         }
         foreach ($modelFields as $column) {
             $columnsSenchaNames[] = isset($column['mapping']) ? $column['mapping'] : $column['name'];
         }
         // get all the column that are not present in the database-table
         $differentCreateColumns = array_diff($columnsSenchaNames, $columnsTableNames);
         $differentDropColumns = array_diff($columnsTableNames, $columnsSenchaNames);
         // unset the id field from both arrays
         unset($differentCreateColumns[MatchaUtils::__recursiveArraySearch('id', $differentCreateColumns)]);
         unset($modelFields[MatchaUtils::__recursiveArraySearch('id', $modelFields)]);
         // deal with the sencha triggers
         self::__diffTriggers(self::$__senchaModel);
         $indexArray = self::__getIndexFields(self::$__senchaModel);
         // check if the table has columns, if not create them.
         if (count($tableColumns) <= 1) {
             self::__createAllColumns($modelFields);
             // add data - if the model has data defined.
             if (isset(self::$__senchaModel['table']['data'])) {
                 $rec = self::$__conn->prepare('SELECT * FROM ' . $table);
                 $rec->execute();
                 if ($rec->rowCount() <= 0) {
                     MatchaModel::__setSenchaModelData(MatchaModel::$__senchaModel['table']['data']);
                 }
             }
             return true;
         } elseif (count($differentCreateColumns) || count($differentDropColumns)) {
             // add columns to the table
             foreach ($differentCreateColumns as $column) {
                 self::__createColumn($modelFields[MatchaUtils::__recursiveArraySearch($column, $modelFields)], $table, in_array($column, $indexArray));
             }
             // remove columns from the table
             foreach ($differentDropColumns as $column) {
                 self::__dropColumn($column);
             }
         } else {
//.........这里部分代码省略.........
开发者ID:songhongji,项目名称:gaiaehr,代码行数:101,代码来源:MatchaModel.php


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