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


PHP Propel::getDatabaseMap方法代碼示例

本文整理匯總了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);
             }
         }
     }
 }
開發者ID:naldz,項目名稱:cyberden,代碼行數:22,代碼來源:AbstractDataHandler.php

示例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;
}
開發者ID:arneau,項目名稱:defender-app,代碼行數:19,代碼來源:lessons.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->databaseMap = Propel::getDatabaseMap('bookstore');
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:5,代碼來源:RelatedMapSymmetricalTest.php

示例4: getTableMap

 public function getTableMap()
 {
     return Propel::getDatabaseMap($this->dbName)->getTableByPhpName($this->class);
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:4,代碼來源:PropelFormatter.php

示例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, ' ');
//.........這裏部分代碼省略.........
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:101,代碼來源:BasePeer.php

示例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');
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:4,代碼來源:DatabaseMapTest.php

示例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;
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:33,代碼來源:ModelCriteria.php


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