当前位置: 首页>>代码示例>>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;未经允许,请勿转载。