本文整理汇总了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
}
示例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;
}
示例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;
}