Where in 在speedphp中如何使用

#1 52833

[table]
[tr][td]1[/td][td]// 这里我们将删除小李的第二条留言,也就是gid=13的记录 [/td][/tr]
[/table]
[table]
[tr][td]2[/td][td]// 构造查找条件 [/td][/tr]
[/table]
[table]
[tr][td]3[/td][td]$conditions = array('gid'=>13); // 构造条件 [/td][/tr]
[/table]
[table]
[tr][td]4[/td][td]$gb = spClass('gb'); [/td][/tr]
[/table]
[table]
[tr][td]5[/td][td]$gb->delete($conditions);  [/td][/tr]
[/table]

已知conditions 变量只能提供的数组只能生成 where gid =13 这样的sql语句
请问想用where gid in(12,13) 这样的语句 只能使用 query()函数吗?

2010-07-23 00:32:50

#2 小双

直接用sql语句就行,

$gb = spClass('gb');
$sql = "SELECT * FROM 表 where gid in ('12','13') ";
$results = $gb->findSql($sql);

2010-07-23 09:10:46

#3 jake

find/findAll的$condition参数也可以是字符串的。代表了where的条件。

比如说 findAll("gid in ('12','13')");就可以了

2010-07-23 09:56:35

#4 52833

对于查找(findsql)可以使用 字符串

那在delete update 中没有设置吗?

如果使用 2楼同学的方法  表段的前缀是不会加上去

2010-07-23 10:35:12

#5 jake

find、findAll、update、delete等这几个的第一个参数$condition都可以用字符串(代表where后面的条件,不是整句SQL)。

findSql是纯粹用SQL语句来进行查找。

2010-07-23 11:48:15

#6 yuanjianhua

终于明白可以这么写

2010-07-24 11:32:11