一个表,主键`id` 列`content` 列`pwd`
当密码(`pwd`)符合数据库记载,则允许修改`content`
那么下面两个方式哪一个是良好的做法?
--------
1. 分成两句sql,先查后改
select * where id=12345
php对返回的这一行数据,根据pwd字段判断是否继续执行下一条sql
update set …… where id=12345
--------
2. 是单一sql语句,捏在一起
update set …… where id=12345 and pwd='password'
根据影响了1行还是0行判断执行成功与否
--------
3. 请问,我要在php中prepare并执行下面语句
update set `content`=:content where id=12345
在php中怎么修改该语句,使得当
empty($array[':content'])===true
时,`content`字段不被修改?
当密码(`pwd`)符合数据库记载,则允许修改`content`
那么下面两个方式哪一个是良好的做法?
--------
1. 分成两句sql,先查后改
select * where id=12345
php对返回的这一行数据,根据pwd字段判断是否继续执行下一条sql
update set …… where id=12345
--------
2. 是单一sql语句,捏在一起
update set …… where id=12345 and pwd='password'
根据影响了1行还是0行判断执行成功与否
--------
3. 请问,我要在php中prepare并执行下面语句
update set `content`=:content where id=12345
在php中怎么修改该语句,使得当
empty($array[':content'])===true
时,`content`字段不被修改?