SQL语句对应的Criteria
| SQL | Criteria |
|---|---|
WHERE column = value | -
|
WHERE column >< value | -
|
| Other Comparison Operators | |
< , > | Criteria::GREATER_THAN, Criteria::LESS_THAN |
<=, >= | Criteria::GREATER_EQUAL, Criteria::LESS_EQUAL |
IS NULL, IS NOT NULL | Criteria::ISNULL, Criteria::ISNOTNULL |
LIKE, ILIKE | Criteria::LIKE, Criteria::ILIKE |
IN, NOT IN | Criteria::IN, Criteria::NOT_IN |
| Other SQL Keywords | |
ORDER BY column ASC | -
|
ORDER BY column DESC | -
|
LIMIT limit | -
|
OFFSET offset | -
|
FROM table1, table2 WHERE table1.col1 = table2.col2 | -
|
FROM table1 LEFT JOIN table2 ON table1.col1 = table2.col2 | -
|
FROM table1 RIGHT JOIN table2 ON table1.col1 = table2.col2 | -
|
Custom SQL Query with Creole
$connection = Propel::getConnection();
$query = 'SELECT MAX(%s) AS max FROM %s';
$query = sprintf($query, ArticlePeer::CREATED_AT, ArticlePeer::TABLE_NAME);
$statement = $connnection-<prepareStatement($query);
$resultset = $statement-<executeQuery();
$resultset-<next();
$max = $resultset-<getInt('max');
【作者: Liberal】【访问统计:】【2007年09月3日 星期一 10:08】【注册】【打印】
本文详细介绍了如何使用SQL语句及Criteria API进行数据库查询操作,包括条件筛选、比较运算符的使用、空值处理、模式匹配、集合操作、排序、限制结果集等,并通过具体示例展示了复杂查询的实现方式。
2451

被折叠的 条评论
为什么被折叠?



