84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
在php中实现一个执行sql update语句的函数,传入参数表名,列值对的数组和where语句。在拼sql语句的时候,是否必须要知道列的类型,是否可以所有列的值都作为字符串处理(用引号括起来)。例如:update table1 set intcol=‘999’ where id=123。这句sql是可以执行通过的,但是可以作为普遍原则吗,有没有特殊的情况?
光阴似箭催人老,日月如移越少年。
供参考:
mysql> create table sf (x boolean); Query OK, 0 rows affected (0.04 sec) mysql> describe sf; +-------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | x | tinyint(1) | YES | | NULL | | +-------+------------+------+-----+---------+-------+ 1 row in set (0.00 sec) mysql> insert into sf values ("true"), ("1"), ("false"), ("0"), (TRUE), (FALSE); Query OK, 6 rows affected, 2 warnings (0.00 sec) Records: 6 Duplicates: 0 Warnings: 0 mysql> select * from sf; +------+ | x | +------+ | 0 | | 1 | | 0 | | 0 | | 1 | | 0 | +------+ 6 rows in set (0.00 sec)
供参考: