在php中实现一个执行sql update语句的函数,传入参数表名,列值对的数组和where语句。在拼sql语句的时候,是否必须要知道列的类型,是否可以所有列的值都作为字符串处理(用引号括起来)。例如:update table1 set intcol=‘999’ where id=123。
1 回答
杨__羊羊
TA贡献1943条经验 获得超7个赞
供参考:
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: 0mysql> select * from sf; +------+| x | +------+| 0 | | 1 | | 0 | | 0 | | 1 | | 0 | +------+6 rows in set (0.00 sec)
添加回答
举报
0/150
提交
取消