本文整理汇总了PHP中Propel\Runtime\Propel::getDatabaseMap方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::getDatabaseMap方法的具体用法?PHP Propel::getDatabaseMap怎么用?PHP Propel::getDatabaseMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Propel
的用法示例。
在下文中一共展示了Propel::getDatabaseMap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadMapBuilders
/**
* Load Map builders.
*
* @param string $connectionName A connection name.
*/
protected function loadMapBuilders($connectionName = null)
{
if (null !== $this->dbMap) {
return;
}
$this->dbMap = Propel::getDatabaseMap($connectionName);
if (0 === count($this->dbMap->getTables())) {
$finder = new Finder();
$files = $finder->files()->name('*TableMap.php')->in($this->getModelSearchPaths($connectionName))->notName('TableMap.php')->exclude('PropelBundle')->exclude('Tests');
foreach ($files as $file) {
$class = $this->guessFullClassName($file->getRelativePath(), basename($file, '.php'));
if (null !== $class && $this->isInDatabase($class, $connectionName)) {
$this->dbMap->addTableFromMapClass($class);
}
}
}
}
示例2: getLessonTags
function getLessonTags($lesson_id, $order_by = 'vote_count')
{
# Get lesson object
$lesson_object = getLesson($lesson_id);
# Get lesson tags IDs
$lesson_tags_ids = $lesson_object->getLessonTags()->getPrimaryKeys();
# Get tag verse column to sort by
$tag_verse_column_to_order_by = Propel::getDatabaseMap()->getTableByPhpName('TagVerse')->getColumnByPhpName('VerseId')->getFullyQualifiedName();
# Get applicable tag objects
$tags_objects = TagQuery::create()->useLessonTagQuery()->filterByPrimaryKeys($lesson_tags_ids)->endUse()->_if($order_by == 'vote_count')->orderByVoteCount()->_elseif($order_by == 'date_tagged')->orderById('DESC')->_endif()->joinWithTagVerse()->addAscendingOrderByColumn($tag_verse_column_to_order_by)->find();
# Handle lesson tags objects
$lesson_tags_to_return = [];
foreach ($tags_objects as $tag_object) {
# Append lesson tag to lesson tags to return
$lesson_tags_to_return[] = ['id' => $tag_object->getId()];
}
# Return lesson tags
return $lesson_tags_to_return;
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$this->databaseMap = Propel::getDatabaseMap('bookstore');
}
示例4: getTableMap
public function getTableMap()
{
return Propel::getDatabaseMap($this->dbName)->getTableByPhpName($this->class);
}
示例5: createSelectSql
/**
* Method to create an SQL query based on values in a Criteria.
*
* This method creates only prepared statement SQL (using ? where values
* will go). The second parameter ($params) stores the values that need
* to be set before the statement is executed. The reason we do it this way
* is to let the PDO layer handle all escaping & value formatting.
*
* @param Criteria $criteria Criteria for the SELECT query.
* @param array &$params Parameters that are to be replaced in prepared statement.
* @return string
* @throws PropelException Trouble creating the query string.
*/
public static function createSelectSql(Criteria $criteria, &$params)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$fromClause = array();
$joinClause = array();
$joinTables = array();
$whereClause = array();
$orderByClause = array();
$orderBy = $criteria->getOrderByColumns();
$groupBy = $criteria->getGroupByColumns();
$ignoreCase = $criteria->isIgnoreCase();
// get the first part of the SQL statement, the SELECT part
$selectSql = $db->createSelectSqlPart($criteria, $fromClause);
// Handle joins
// joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause.
// joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause
foreach ($criteria->getJoins() as $join) {
$join->setDB($db);
// add 'em to the queues..
if (!$fromClause) {
$fromClause[] = $join->getLeftTableWithAlias();
}
$joinTables[] = $join->getRightTableWithAlias();
$joinClause[] = $join->getClause($params);
}
// add the criteria to WHERE clause
// this will also add the table names to the FROM clause if they are not already
// included via a LEFT JOIN
foreach ($criteria->keys() as $key) {
$criterion = $criteria->getCriterion($key);
$table = null;
foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
$tableName = $attachedCriterion->getTable();
$table = $criteria->getTableForAlias($tableName);
if ($table !== null) {
$fromClause[] = $table . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
$table = $tableName;
}
if (($criteria->isIgnoreCase() || $attachedCriterion->isIgnoreCase()) && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) {
$attachedCriterion->setIgnoreCase(true);
}
}
$criterion->setDB($db);
$sb = '';
$criterion->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
// Unique from clause elements
$fromClause = array_unique($fromClause);
$fromClause = array_diff($fromClause, array(''));
// tables should not exist in both the from and join clauses
if ($joinTables && $fromClause) {
foreach ($fromClause as $fi => $ftable) {
if (in_array($ftable, $joinTables)) {
unset($fromClause[$fi]);
}
}
}
// Add the GROUP BY columns
$groupByClause = $groupBy;
$having = $criteria->getHaving();
$havingString = null;
if ($having !== null) {
$sb = '';
$having->appendPsTo($sb, $params);
$havingString = $sb;
}
if (!empty($orderBy)) {
foreach ($orderBy as $orderByColumn) {
// Add function expression as-is.
if (strpos($orderByColumn, '(') !== false) {
$orderByClause[] = $orderByColumn;
continue;
}
// Split orderByColumn (i.e. "table.column DESC")
$dotPos = strrpos($orderByColumn, '.');
if ($dotPos !== false) {
$tableName = substr($orderByColumn, 0, $dotPos);
$columnName = substr($orderByColumn, $dotPos + 1);
} else {
$tableName = '';
$columnName = $orderByColumn;
}
$spacePos = strpos($columnName, ' ');
//.........这里部分代码省略.........
示例6: testGetTableByPhpNameNotLoaded
public function testGetTableByPhpNameNotLoaded()
{
$this->assertEquals('book', Propel::getDatabaseMap('bookstore')->getTableByPhpName('Book')->getName(), 'getTableByPhpName() can autoload a TableMap when the Peer class is generated and autoloaded');
}
示例7: getParams
/**
* Get all the parameters to bind to this criteria
* Does part of the job of BasePeer::createSelectSql() for the cache
*
* @return array list of parameters, each parameter being an array like
* array('table' => $realtable, 'column' => $column, 'value' => $value)
*/
public function getParams()
{
$params = array();
$dbMap = Propel::getDatabaseMap($this->getDbName());
foreach ($this->getMap() as $criterion) {
$table = null;
foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
$tableName = $attachedCriterion->getTable();
$table = $this->getTableForAlias($tableName);
if (null === $table) {
$table = $tableName;
}
if (($this->isIgnoreCase() || $attachedCriterion->isIgnoreCase()) && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) {
$attachedCriterion->setIgnoreCase(true);
}
}
$sb = '';
$criterion->appendPsTo($sb, $params);
}
$having = $this->getHaving();
if ($having !== null) {
$sb = '';
$having->appendPsTo($sb, $params);
}
return $params;
}