在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
提交
取消