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


PHP ModelCriteria::withColumn方法代碼示例

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


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

示例1: testWithColumnAndSelectColumns

 public function testWithColumnAndSelectColumns()
 {
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->withColumn('UPPER(Propel\\Tests\\Bookstore\\Book.Title)', 'foo');
     $sql = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, UPPER(book.title) AS foo FROM book');
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds the object columns if the criteria has no select columns');
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->addSelectColumn('book.id');
     $c->withColumn('UPPER(Propel\\Tests\\Bookstore\\Book.Title)', 'foo');
     $sql = $this->getSql('SELECT book.id, UPPER(book.title) AS foo FROM book');
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() does not add the object columns if the criteria already has select columns');
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->addSelectColumn('book.id');
     $c->withColumn('UPPER(Propel\\Tests\\Bookstore\\Book.Title)', 'foo');
     $c->addSelectColumn('book.title');
     $sql = $this->getSql('SELECT book.id, book.title, UPPER(book.title) AS foo FROM book');
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() does adds as column after the select columns even though the withColumn() method was called first');
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->addSelectColumn('book.id');
     $c->withColumn('UPPER(Propel\\Tests\\Bookstore\\Book.Title)', 'foo');
     $c->withColumn('UPPER(Propel\\Tests\\Bookstore\\Book.isbn)', 'isbn');
     $sql = $this->getSql('SELECT book.id, UPPER(book.title) AS foo, UPPER(book.isbn) AS isbn FROM book');
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() called repeatedly adds several as columns');
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:28,代碼來源:ModelCriteriaTest.php

示例2: testFindOneWithClassAndColumn

 public function testFindOneWithClassAndColumn()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
     $c->filterByTitle('The Tin Drum');
     $c->join('Propel\\Tests\\Bookstore\\Book.Author');
     $c->withColumn('Author.FirstName', 'AuthorName');
     $c->withColumn('Author.LastName', 'AuthorName2');
     $c->with('Author');
     $c->limit(1);
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $books = $c->find($con);
     foreach ($books as $book) {
         break;
     }
     $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class');
     $this->assertEquals('The Tin Drum', $book->getTitle());
     $this->assertTrue($book->getAuthor() instanceof Author, 'ObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'ObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'ObjectFormatter adds withColumns as virtual columns');
     $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'ObjectFormatter correctly hydrates all virtual columns');
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:26,代碼來源:OnDemandFormatterWithTest.php

示例3: selectCategoryAttributeColumns

 /**
  * @api
  *
  * @param \Propel\Runtime\ActiveQuery\ModelCriteria $expandableQuery
  * @param string $tableAlias
  *
  * @return \Propel\Runtime\ActiveQuery\ModelCriteria
  */
 public function selectCategoryAttributeColumns(ModelCriteria $expandableQuery, $tableAlias = SpyCategoryAttributeTableMap::TABLE_NAME)
 {
     $expandableQuery->withColumn($tableAlias . '.name', 'category_name');
     $expandableQuery->withColumn($tableAlias . '.meta_title', 'category_meta_title');
     $expandableQuery->withColumn($tableAlias . '.meta_description', 'category_meta_description');
     $expandableQuery->withColumn($tableAlias . '.meta_keywords', 'category_meta_keywords');
     $expandableQuery->withColumn($tableAlias . '.category_image_name', 'category_image_name');
     return $expandableQuery;
 }
開發者ID:spryker,項目名稱:Category,代碼行數:17,代碼來源:CategoryQueryContainer.php

示例4: joinTaxRates

 /**
  * @api
  *
  * @param \Propel\Runtime\ActiveQuery\ModelCriteria $expandableQuery
  *
  * @return $this
  */
 public function joinTaxRates(ModelCriteria $expandableQuery)
 {
     $expandableQuery->addJoin(SpyTaxSetTableMap::COL_ID_TAX_SET, SpyTaxSetTaxTableMap::COL_FK_TAX_SET, Criteria::LEFT_JOIN)->addJoin(SpyTaxSetTaxTableMap::COL_FK_TAX_RATE, SpyTaxRateTableMap::COL_ID_TAX_RATE, Criteria::LEFT_JOIN);
     $expandableQuery->withColumn('GROUP_CONCAT(DISTINCT ' . SpyTaxRateTableMap::COL_NAME . ')', 'tax_rate_names')->withColumn('GROUP_CONCAT(DISTINCT ' . SpyTaxRateTableMap::COL_RATE . ')', 'tax_rate_rates');
     return $this;
 }
開發者ID:spryker,項目名稱:Tax,代碼行數:13,代碼來源:TaxQueryContainer.php

示例5: mapToOneRelationFields

 /**
  * @param ModelCriteria $query
  * @param RelationMap[] $relations
  * @param string[][] $relationFields
  */
 public function mapToOneRelationFields(&$query, $relations, $relationFields)
 {
     if ($relations) {
         foreach ($relations as $name => $relation) {
             if ($relation->getType() != RelationMap::MANY_TO_MANY && $relation->getType() != RelationMap::ONE_TO_MANY) {
                 $query->{'join' . $name}($name);
                 //$query->with($name);
                 if (isset($relationFields[$name])) {
                     foreach ($relationFields[$name] as $col) {
                         $query->withColumn($name . "." . $col, '"' . $name . "." . $col . '"');
                     }
                 }
             }
         }
     }
 }
開發者ID:jarves,項目名稱:jarves,代碼行數:21,代碼來源:Propel.php

示例6: testSelectArrayWithColumn

 public function testSelectArrayWithColumn()
 {
     BookstoreDataPopulator::depopulate($this->con);
     BookstoreDataPopulator::populate($this->con);
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->join('Propel\\Tests\\Bookstore\\Book.Author');
     $c->withColumn('LOWER(Propel\\Tests\\Bookstore\\Book.Title)', 'LowercaseTitle');
     $c->select(array('LowercaseTitle', 'Propel\\Tests\\Bookstore\\Book.Title'));
     $c->orderBy('Propel\\Tests\\Bookstore\\Book.Title');
     $rows = $c->find($this->con);
     $expectedSQL = $this->getSql('SELECT LOWER(book.TITLE) AS LowercaseTitle, book.TITLE AS "Propel\\Tests\\Bookstore\\Book.Title" FROM `book` INNER JOIN `author` ON (book.AUTHOR_ID=author.ID) ORDER BY book.TITLE ASC');
     $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) can cope with a column added with withColumn()');
     $expectedRows = array(array('LowercaseTitle' => 'don juan', 'Propel\\Tests\\Bookstore\\Book.Title' => 'Don Juan'), array('LowercaseTitle' => 'harry potter and the order of the phoenix', 'Propel\\Tests\\Bookstore\\Book.Title' => 'Harry Potter and the Order of the Phoenix'), array('LowercaseTitle' => 'quicksilver', 'Propel\\Tests\\Bookstore\\Book.Title' => 'Quicksilver'), array('LowercaseTitle' => 'the tin drum', 'Propel\\Tests\\Bookstore\\Book.Title' => 'The Tin Drum'));
     $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) can cope with a column added with withColumn()');
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:15,代碼來源:ModelCriteriaSelectTest.php

示例7: testFindOneWithClassAndColumn

 public function testFindOneWithClassAndColumn()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $c = new ModelCriteria('bookstore', '\\Propel\\Tests\\Bookstore\\Book');
     $c->setFormatter(ModelCriteria::FORMAT_ARRAY);
     $c->filterByTitle('The Tin Drum');
     $c->join('Propel\\Tests\\Bookstore\\Book.Author');
     $c->withColumn('Author.FirstName', 'AuthorName');
     $c->withColumn('Author.LastName', 'AuthorName2');
     $c->with('Author');
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $book = $c->findOne($con);
     $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Author', 'AuthorName', 'AuthorName2'), array_keys($book), 'withColumn() do not change the resulting model class');
     $this->assertEquals('The Tin Drum', $book['Title']);
     $this->assertEquals('Gunter', $book['Author']['FirstName'], 'ArrayFormatter correctly hydrates withclass and columns');
     $this->assertEquals('Gunter', $book['AuthorName'], 'ArrayFormatter adds withColumns as columns');
     $this->assertEquals('Grass', $book['AuthorName2'], 'ArrayFormatter correctly hydrates all as columns');
 }
開發者ID:badelas,項目名稱:thelia,代碼行數:21,代碼來源:ArrayFormatterWithTest.php

示例8: getBackEndI18n

 public static function getBackEndI18n(ModelCriteria &$search, $requestedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID')
 {
     if ($foreignTable === null) {
         $foreignTable = $search->getTableMap()->getName();
         $aliasPrefix = '';
     } else {
         $aliasPrefix = $foreignTable . '_';
     }
     $requestedLocaleI18nAlias = $aliasPrefix . 'requested_locale_i18n';
     $requestedLocaleJoin = new Join();
     $requestedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias);
     $requestedLocaleJoin->setJoinType(Criteria::LEFT_JOIN);
     $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)->addJoinCondition($requestedLocaleI18nAlias, '`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR);
     $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED');
     foreach ($columns as $column) {
         $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column);
     }
 }
開發者ID:badelas,項目名稱:thelia,代碼行數:18,代碼來源:ModelCriteriaTools.php

示例9: joinProductQueryWithLocalizedAttributes

 /**
  * @api
  *
  * @param \Propel\Runtime\ActiveQuery\ModelCriteria $expandableQuery
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return $this
  */
 public function joinProductQueryWithLocalizedAttributes(ModelCriteria $expandableQuery, LocaleTransfer $locale)
 {
     $expandableQuery->addJoin(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, SpyProductAbstractLocalizedAttributesTableMap::COL_FK_PRODUCT_ABSTRACT, Criteria::INNER_JOIN);
     $expandableQuery->addJoin(SpyProductAbstractLocalizedAttributesTableMap::COL_FK_LOCALE, SpyLocaleTableMap::COL_ID_LOCALE, Criteria::INNER_JOIN);
     $expandableQuery->addAnd(SpyLocaleTableMap::COL_ID_LOCALE, $locale->getIdLocale(), Criteria::EQUAL);
     $expandableQuery->addAnd(SpyLocaleTableMap::COL_IS_ACTIVE, true, Criteria::EQUAL);
     $expandableQuery->addJoinObject((new Join(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, SpyUrlTableMap::COL_FK_RESOURCE_PRODUCT_ABSTRACT, Criteria::LEFT_JOIN))->setRightTableAlias('product_urls'), 'productUrlsJoin');
     $expandableQuery->addJoinCondition('productUrlsJoin', 'product_urls.fk_locale = ' . SpyLocaleTableMap::COL_ID_LOCALE);
     $expandableQuery->addJoinObject(new Join(SpyProductTableMap::COL_ID_PRODUCT, SpyProductLocalizedAttributesTableMap::COL_FK_PRODUCT, Criteria::INNER_JOIN), 'productAttributesJoin');
     $expandableQuery->addJoinCondition('productAttributesJoin', SpyProductLocalizedAttributesTableMap::COL_FK_LOCALE . ' = ' . SpyLocaleTableMap::COL_ID_LOCALE);
     $expandableQuery->withColumn(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, 'id_product_abstract');
     $expandableQuery->withColumn(SpyProductAbstractTableMap::COL_ATTRIBUTES, 'abstract_attributes');
     $expandableQuery->withColumn(SpyProductAbstractLocalizedAttributesTableMap::COL_ATTRIBUTES, 'abstract_localized_attributes');
     $expandableQuery->withColumn("GROUP_CONCAT(spy_product.attributes SEPARATOR '\$%')", 'concrete_attributes');
     $expandableQuery->withColumn("GROUP_CONCAT(spy_product_localized_attributes.attributes SEPARATOR '\$%')", 'concrete_localized_attributes');
     $expandableQuery->withColumn('GROUP_CONCAT(product_urls.url)', 'product_urls');
     $expandableQuery->withColumn(SpyProductAbstractLocalizedAttributesTableMap::COL_NAME, 'abstract_name');
     $expandableQuery->withColumn('GROUP_CONCAT(spy_product_localized_attributes.name)', 'concrete_names');
     return $this;
 }
開發者ID:spryker,項目名稱:Product,代碼行數:28,代碼來源:ProductQueryContainer.php

示例10: addExtraColumns

 /**
  * Add extra columns to pagination query
  *
  * @param ModelCriteria $query
  */
 private function addExtraColumns(ModelCriteria &$query)
 {
     if (!empty($this->extraColumns)) {
         foreach ($this->extraColumns as $expression => $columnName) {
             $query->withColumn($expression, $columnName);
         }
     }
 }
開發者ID:c15k0,項目名稱:psfs,代碼行數:13,代碼來源:Api.php


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