- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- PHP-Propel/SELECT へ行く。
SELECT
$c->add(AuthorPeer::NAME, "taro"); // WHERE name = 'taro' $c->add(AuthorPeer::NAME, "taro", Criteria::NOT_EQUAL); // WHERE name <> 'taro'
Criteriaオペレーター
- EQUAL (デフォルト)
- NOT_EQUAL
- GREATER_THAN
- LESS_THAN
- GREATER_EQUAL
- LESS_EQUAL
- LIKE
- NOT_LIKE
- IN
- CUSTOM
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
LEFT OUTER JOIN 他
$c->addJoin(ItemPeer::CATETORY_ID, CategoryPeer::ID, 'LEFT OUTER JOIN');
ORDER BY
$c->addAscendingOrderByColumn(ItemPeer::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
カラム名を指定して取得(設定)
$age = $row->getByName('age'); $row->setByName('age') = 18;