ttgive / qeephp

Automatically exported from code.google.com/p/qeephp
0 stars 0 forks source link

添加 QDB_Table::createExpr() 方法 #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
QDB_Table::createExpr() 方法返回一个 QDB_Expr 对象。

好处在于可以在 QDB_Table::createExpr() 
中对表达式包含的字段名进行自动转义,例如:

{{{
$expr = $table_posts->createExpr('LEFT([title], 5)');
// $expr 的内容是 LEFT(`posts`.`title`, 5)
}}}

更进一步,当在 QDB_Select 中使用该 QDB_Expr 
对象时,表名称可以自动替换为由开发者指
定的表别名。

{{{
// SELECT LEFT(`p`.`title, 5) FROM `posts` `p`
$select->from(array('p' => 'posts'), $expr);
}}}

Original issue reported on code.google.com by dualf...@gmail.com on 21 Apr 2008 at 8:16

GoogleCodeExporter commented 9 years ago
嗯嗯,这个方法多余了。

QDB_Expr() 
直接支持对“[字段名]”的解析即可。具体的表名称和 schema 
可以在 QDB_Select 中使用
该表达式对象时确定。

Original comment by dualf...@gmail.com on 21 Apr 2008 at 8:26