php进行插入记录到Mysql中,出现了一种情况就是插入成功,可以返回插入的记录id,但是mysql当中无记录,语句如下:
INSERT INTO `#__vc_transactions` SET `title`='现金币' , `units`='3' , `txn_id`='5FF0BDB3C815A69C' , `txn_amount`='3' , `txn_currency`='CNY' , `txn_status`='pending' , `txn_date`='2016-12-23 06:32:38' , `extra_data`=NULL , `service_provider`='System' , `service_alias`='' , `item_id`='2' , `item_type`='currency' , `sender_id`='0' , `receiver_id`='50' , `custom_price`='0' , `order_status`='transfer' , `transfer_type`='1' , `bank`='1'但是,于此同时,下面这段语句就插入成功,并且mysql中也有记录:
INSERT INTO `#__vc_transactions` SET `title`='现金币' , `units`='50' , `txn_id`='8DE6C35ED5CD9569' , `txn_amount`='45' , `txn_currency`='CNY' , `txn_status`='completed' , `txn_date`='2016-12-23 06:32:00' , `extra_data`='手续费:5' , `service_provider`='System' , `service_alias`='' , `item_id`='2' , `item_type`='currency' , `sender_id`='50' , `receiver_id`='47' , `custom_price`='0' , `order_status`='transfer' , `transfer_type`='2' , `bank`='0'这两句有什么根本区别吗?为什么上面那个语句mysql中就无记录呢?
请教大神!
INSERT INTO `#__vc_transactions` SET `title`='现金币' , `units`='3' , `txn_id`='5FF0BDB3C815A69C' , `txn_amount`='3' , `txn_currency`='CNY' , `txn_status`='pending' , `txn_date`='2016-12-23 06:32:38' , `extra_data`=NULL , `service_provider`='System' , `service_alias`='' , `item_id`='2' , `item_type`='currency' , `sender_id`='0' , `receiver_id`='50' , `custom_price`='0' , `order_status`='transfer' , `transfer_type`='1' , `bank`='1'但是,于此同时,下面这段语句就插入成功,并且mysql中也有记录:
INSERT INTO `#__vc_transactions` SET `title`='现金币' , `units`='50' , `txn_id`='8DE6C35ED5CD9569' , `txn_amount`='45' , `txn_currency`='CNY' , `txn_status`='completed' , `txn_date`='2016-12-23 06:32:00' , `extra_data`='手续费:5' , `service_provider`='System' , `service_alias`='' , `item_id`='2' , `item_type`='currency' , `sender_id`='50' , `receiver_id`='47' , `custom_price`='0' , `order_status`='transfer' , `transfer_type`='2' , `bank`='0'这两句有什么根本区别吗?为什么上面那个语句mysql中就无记录呢?
请教大神!
我修改了插入语句,但是问题依然存在:
第一个是可以插入成功的:
INSERT INTO `#__vc_transactions` (`title`,`units`,`txn_id`,`txn_amount`,`txn_currency`,`txn_status`,`txn_date`,`extra_data`,`service_provider`,`service_alias`,`item_id`,`item_type`,`sender_id`,`receiver_id`,`custom_price`,`order_status`,`transfer_type`,`bank`) VALUES ('现金币','50','EE2CE817052183C2','45','CNY','completed','2016-12-28 02:33:00','手续费:5','系统','','2','currency','50','47','0','transfer','2','0')
第二个是不能插入成功的:
INSERT INTO `#__vc_transactions` (`title`,`units`,`txn_id`,`txn_amount`,`txn_currency`,`txn_status`,`txn_date`,`extra_data`,`service_provider`,`service_alias`,`item_id`,`item_type`,`sender_id`,`receiver_id`,`custom_price`,`order_status`,`transfer_type`,`bank`) VALUES ('现金币','1','C5EAE30FBC59425F','1','CNY','pending','2016-12-28 02:34:35',NULL,'系统','','2','currency','0','50','0','transfer','1','1')下面是我的数据库结构:
units decimal(10,2) UNSIGNED No None
txn_idIndex varchar(255) No None
txn_amount decimal(10,2) No 0.00
txn_currency varchar(8) No None
txn_status enum('pending', 'completed', 'canceled', 'refunded... No pending
txn_date timestamp No CURRENT_TIMESTAMP
extra_data varchar(2048) Yes NULL
service_provider varchar(32) No None
service_alias varchar(32) No None
sender_id int(10) UNSIGNED No None
receiver_id int(10) UNSIGNED No None
item_id tinyint(3) UNSIGNED No None
item_type enum('currency', 'commodity') No None
shared_amount decimal(10,2) No None
custom_price decimal(10,2) No None
order_status enum('transfer', 'onsale', 'waiting_proof', 'watin... Yes NULL
transfer_type int(1) No 1
bank int(10) UNSIGNED No None
所以你第二句传NULL是不行的
改为
INSERT INTO `#__vc_transactions` (`title`,`units`,`txn_id`,`txn_amount`,`txn_currency`,`txn_status`,`txn_date`,`extra_data`,`service_provider`,`service_alias`,`item_id`,`item_type`,`sender_id`,`receiver_id`,`custom_price`,`order_status`,`transfer_type`,`bank`) VALUES ('现金币','1','C5EAE30FBC59425F','1','CNY','pending','2016-12-28 02:34:35','','系统','','2','currency','0','50','0','transfer','1','1')