本文整理汇总了PHP中ModelCriteria::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelCriteria::orderBy方法的具体用法?PHP ModelCriteria::orderBy怎么用?PHP ModelCriteria::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelCriteria
的用法示例。
在下文中一共展示了ModelCriteria::orderBy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindOneWithUsingInstancePool
public function testFindOneWithUsingInstancePool()
{
BookstoreDataPopulator::populate();
// instance pool contains all objects by default, since they were just populated
$c = new ModelCriteria('bookstore', 'Book');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
$c->orderBy('Book.Title');
$c->join('Book.Author');
$c->with('Author');
$c->join('Book.Publisher');
$c->with('Publisher');
$this->assertCorrectHydration1($c, 'with instance pool');
}
示例2: testFindOneWithoutUsingInstancePool
public function testFindOneWithoutUsingInstancePool()
{
BookstoreDataPopulator::populate();
Propel::disableInstancePooling();
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Book.Title');
$c->join('Book.Author');
$c->with('Author');
$c->join('Book.Publisher');
$c->with('Publisher');
$this->assertCorrectHydration1($c, 'without instance pool');
Propel::enableInstancePooling();
}
示例3: testFindOne
public function testFindOne()
{
$c = new ModelCriteria('bookstore', 'Book', 'b');
$c->where('b.Title = ?', 'foo');
$book = $c->findOne();
$this->assertNull($book, 'findOne() returns null when the query returns no result');
$c = new ModelCriteria('bookstore', 'Book', 'b');
$c->orderBy('b.Title');
$book = $c->findOne();
$this->assertTrue($book instanceof Book, 'findOne() returns a Model object by default');
$this->assertEquals('Don Juan', $book->getTitle(), 'find() returns the model objects matching the query');
}
示例4: testFindPksSimpleKey
public function testFindPksSimpleKey()
{
BookstoreDataPopulator::depopulate();
BookstoreDataPopulator::populate();
BookPeer::clearInstancePool();
// prepare the test data
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Book.Id', 'desc');
$testBooks = $c->find();
$testBook1 = $testBooks->pop();
$testBook2 = $testBooks->pop();
$q = new BookQuery();
$books = $q->findPks(array($testBook1->getId(), $testBook2->getId()));
$this->assertEquals(array($testBook1, $testBook2), $books->getData(), 'BaseQuery overrides findPks() to make it faster');
}
示例5: testOrderByWithInsensitiveCase
public function testOrderByWithInsensitiveCase()
{
$sql = 'SELECT FROM ORDER BY book.TITLE ASC';
$params = array();
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Book.title');
$this->assertCriteriaTranslation($c, $sql, $params);
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Book.TiTle');
$this->assertCriteriaTranslation($c, $sql, $params);
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Book.Title');
$this->assertCriteriaTranslation($c, $sql, $params);
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Book.TITLE');
$this->assertCriteriaTranslation($c, $sql, $params);
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('title');
$this->assertCriteriaTranslation($c, $sql, $params);
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('Title');
$this->assertCriteriaTranslation($c, $sql, $params);
$c = new ModelCriteria('bookstore', 'Book');
$c->orderBy('TITLE');
$this->assertCriteriaTranslation($c, $sql, $params);
}
示例6: testSelectArrayWithColumn
public function testSelectArrayWithColumn()
{
BookstoreDataPopulator::depopulate($this->con);
BookstoreDataPopulator::populate($this->con);
$c = new ModelCriteria('bookstore', 'Book');
$c->join('Book.Author');
$c->withColumn('LOWER(Book.Title)', 'LowercaseTitle');
$c->select(array('LowercaseTitle', 'Book.Title'));
$c->orderBy('Book.Title');
$rows = $c->find($this->con);
$expectedSQL = 'SELECT LOWER(book.TITLE) AS LowercaseTitle, book.TITLE AS "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', 'Book.Title' => 'Don Juan'), array('LowercaseTitle' => 'harry potter and the order of the phoenix', 'Book.Title' => 'Harry Potter and the Order of the Phoenix'), array('LowercaseTitle' => 'quicksilver', 'Book.Title' => 'Quicksilver'), array('LowercaseTitle' => 'the tin drum', '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()');
}
示例7: testSelectArrayWithColumnOrder
public function testSelectArrayWithColumnOrder()
{
BookstoreDataPopulator::depopulate($this->con);
BookstoreDataPopulator::populate($this->con);
$c = new ModelCriteria('bookstore', 'Book');
$c->join('Book.Author');
$c->withColumn('LOWER(Book.Title)', 'LowercaseTitle');
$c->withColumn('UPPER(Book.Title)', 'UppercaseTitle');
$c->select(array('Book.ISBN', 'LowercaseTitle', 'Book.Title', 'UppercaseTitle'));
$c->orderBy('Book.Title');
$rows = $c->find($this->con);
$expectedSQL = 'SELECT book.isbn AS "Book.ISBN", LOWER(book.title) AS LowercaseTitle, book.title AS "Book.Title", UPPER(book.title) AS UppercaseTitle 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('Book.ISBN' => '0140422161', 'LowercaseTitle' => 'don juan', 'Book.Title' => 'Don Juan', 'UppercaseTitle' => 'DON JUAN'), array('Book.ISBN' => '043935806X', 'LowercaseTitle' => 'harry potter and the order of the phoenix', 'Book.Title' => 'Harry Potter and the Order of the Phoenix', 'UppercaseTitle' => 'HARRY POTTER AND THE ORDER OF THE PHOENIX'), array('Book.ISBN' => '0380977427', 'LowercaseTitle' => 'quicksilver', 'Book.Title' => 'Quicksilver', 'UppercaseTitle' => 'QUICKSILVER'), array('Book.ISBN' => '067972575X', 'LowercaseTitle' => 'the tin drum', 'Book.Title' => 'The Tin Drum', 'UppercaseTitle' => 'THE TIN DRUM'));
$this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) can cope with a column added with withColumn()');
}