- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- PHP-Propel/SELECT へ行く。
SELECT
$c->add(AuthorPeer::NAME, "taro"); // WHERE name = 'taro' $c->add(AuthorPeer::NAME, "taro", Criteria::NOT_EQUAL); // WHERE name <> 'taro'
JOIN
$c = new Criteria(); $c->addJoin(ItemPeer::CATETORY_ID, CategoryPeer::ID, Criteria::INNER_JOIN); $itemList = ItemPeer::doSelect($c); // SELECT * FROM item JOIN category ON item.category_id = category.id
GROUP BYしてCOUNT()
SELECT COUNT(category_id) FROM item GROUP BY category_id
$c->addSelectColumn('COUNT('.ItemPeer::CATEGORY_ID.')'); $c->addSelectColumn(ItemPeer::CATEGORY_ID); $c->addGroupByColumn(ItemPeer::CATEGORY_ID) ; $stmt = ItemPeer::doSelectStmt($c); $rows = $stmt->fetchAll(PDO::FETCH_NUM); foreach ($rows as $r) { $count = $r[0]; $category_id = $r[1]; }
http://old.nabble.com/How-to-use-aggregate-functions--td18385850.html
参考
http://propel.phpdb.org/trac/wiki/Ja/Users/Documentation/1.2/UserGuide