當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Criteria::getTableName方法代碼示例

本文整理匯總了PHP中Criteria::getTableName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::getTableName方法的具體用法?PHP Criteria::getTableName怎麽用?PHP Criteria::getTableName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Criteria的用法示例。


在下文中一共展示了Criteria::getTableName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doBackupRecord

 public static function doBackupRecord(\Criteria $criteria, PropelPDO $con)
 {
     $db = Propel::getDB($criteria->getDbName());
     $dbMap = Propel::getDatabaseMap($criteria->getDbName());
     $keys = $criteria->keys();
     if (!empty($keys)) {
         $tableName = $criteria->getTableName($keys[0]);
     } else {
         throw new PropelException("Database insert attempted without anything specified to insert");
     }
     $tableMap = $dbMap->getTable($tableName);
     $whereClause = array();
     $peer = $tableMap->getPeerClassname();
     $versionTable = $peer::$workspaceBehaviorVersionName;
     $originTable = $tableMap->getName();
     $tables = $criteria->getTablesColumns();
     if (empty($tables)) {
         throw new \PropelException("Empty Criteria");
     }
     $fields = array_keys($tableMap->getColumns());
     $fields = implode(', ', $fields);
     foreach ($tables as $tableName => $columns) {
         $whereClause = array();
         $params = array();
         $stmt = null;
         try {
             foreach ($columns as $colName) {
                 $sb = "";
                 $criteria->getCriterion($colName)->appendPsTo($sb, $params);
                 $whereClause[] = $sb;
             }
             $sql = sprintf("INSERT INTO %s (%s) SELECT %s FROM %s WHERE %s", $versionTable, $fields, $fields, $originTable, implode(" AND ", $whereClause));
             $stmt = $con->prepare($sql);
             $db->bindValues($stmt, $params, $dbMap);
             $stmt->execute();
             $stmt->closeCursor();
         } catch (Exception $e) {
             Propel::log($e->getMessage(), Propel::LOG_ERR);
             throw new PropelException(sprintf('Unable to execute INSERT INTO statement [%s]', $sql), $e);
         }
     }
     // for each table
 }
開發者ID:marcj,項目名稱:propel-workspace-behavior,代碼行數:43,代碼來源:WorkspaceBehaviorPeer.php

示例2: getPrimaryKey

 /**
  * Helper method which returns the primary key contained
  * in the given Criteria object.
  *
  * @param      Criteria $criteria A Criteria.
  * @return     ColumnMap If the Criteria object contains a primary
  *		  key, or null if it doesn't.
  * @throws     PropelException
  */
 private static function getPrimaryKey(Criteria $criteria)
 {
     // Assume all the keys are for the same table.
     $keys = $criteria->keys();
     $key = $keys[0];
     $table = $criteria->getTableName($key);
     $pk = null;
     if (!empty($table)) {
         $dbMap = Propel::getDatabaseMap($criteria->getDbName());
         $pks = $dbMap->getTable($table)->getPrimaryKeys();
         if (!empty($pks)) {
             $pk = array_shift($pks);
         }
     }
     return $pk;
 }
開發者ID:RadioCampusFrance,項目名稱:airtime,代碼行數:25,代碼來源:BasePeer.php

示例3: getPrimaryKey

 /**
  * Helper method which returns the primary key contained
  * in the given Criteria object.
  *
  * @param Criteria $criteria A Criteria.
  * @return ColumnMap If the Criteria object contains a primary
  *		  key, or null if it doesn't.
  * @throws PropelException
  */
 private static function getPrimaryKey(Criteria $criteria)
 {
     // Assume all the keys are for the same table.
     $keys = $criteria->keys();
     $key = $keys[0];
     $table = $criteria->getTableName($key);
     $pk = null;
     if (!empty($table)) {
         $dbMap = Propel::getDatabaseMap($criteria->getDbName());
         if ($dbMap === null) {
             throw new PropelException("\$dbMap is null");
         }
         if ($dbMap->getTable($table) === null) {
             throw new PropelException("\$dbMap->getTable() is null");
         }
         $columns = $dbMap->getTable($table)->getColumns();
         foreach (array_keys($columns) as $key) {
             if ($columns[$key]->isPrimaryKey()) {
                 $pk = $columns[$key];
                 break;
             }
         }
     }
     return $pk;
 }
開發者ID:rodrigoprestesmachado,項目名稱:whiteboard,代碼行數:34,代碼來源:BasePeer.php


注:本文中的Criteria::getTableName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。