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


PHP DatabaseConnection::sql_field_type方法代码示例

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


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

示例1: compareFieldArrayWithCurrentAndUnset

 /**
  * Compares the incoming field array with the current record and unsets all fields which are the same.
  * Used for existing records being updated
  *
  * @param string $table Record table name
  * @param int $id Record uid
  * @param array $fieldArray Array of field=>value pairs intended to be inserted into the database. All keys with values matching exactly the current value will be unset!
  * @return array Returns $fieldArray. If the returned array is empty, then the record should not be updated!
  */
 public function compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray)
 {
     // Fetch the original record:
     $res = $this->databaseConnection->exec_SELECTquery('*', $table, 'uid=' . (int) $id);
     $currentRecord = $this->databaseConnection->sql_fetch_assoc($res);
     // If the current record exists (which it should...), begin comparison:
     if (is_array($currentRecord)) {
         // Read all field types:
         $c = 0;
         $cRecTypes = array();
         foreach ($currentRecord as $col => $val) {
             $cRecTypes[$col] = $this->databaseConnection->sql_field_type($res, $c);
             $c++;
         }
         // Free result:
         $this->databaseConnection->sql_free_result($res);
         // Unset the fields which are similar:
         foreach ($fieldArray as $col => $val) {
             $fieldConfiguration = $GLOBALS['TCA'][$table]['columns'][$col]['config'];
             $isNullField = !empty($fieldConfiguration['eval']) && GeneralUtility::inList($fieldConfiguration['eval'], 'null');
             // Unset fields if stored and submitted values are equal - except the current field holds MM relations.
             // In general this avoids to store superfluous data which also will be visualized in the editing history.
             if (!$fieldConfiguration['MM'] && $this->isSubmittedValueEqualToStoredValue($val, $currentRecord[$col], $cRecTypes[$col], $isNullField)) {
                 unset($fieldArray[$col]);
             } else {
                 if (!isset($this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col])) {
                     $this->historyRecords[$table . ':' . $id]['oldRecord'][$col] = $currentRecord[$col];
                 } elseif ($this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col] != $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col]) {
                     $this->historyRecords[$table . ':' . $id]['oldRecord'][$col] = $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col];
                 }
                 if (!isset($this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col])) {
                     $this->historyRecords[$table . ':' . $id]['newRecord'][$col] = $fieldArray[$col];
                 } elseif ($this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col] != $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col]) {
                     $this->historyRecords[$table . ':' . $id]['newRecord'][$col] = $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col];
                 }
             }
         }
     } else {
         // If the current record does not exist this is an error anyways and we just return an empty array here.
         $fieldArray = array();
     }
     return $fieldArray;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:52,代码来源:DataHandler.php


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