我正在尝试使用PhoneGap为android创建一个销售点应用程序,所以我使用HTML5,JS,CSS创建了前端
我使用MySQL作为后端和PHP的服务器端脚本。我已经为用户创建了登录,并成功地为购买选择了商店。现在我在数据库更新中感到困惑
我的情况是我有以下表在mysql
表:pos_masterCREATE TABLE `ordermaster` (
`ordid` int(11) NOT NULL AUTO_INCREMENT,
`wid` int(11) NOT NULL,
`repid` int(11) NOT NULL,
`orddate` datetime NOT NULL,
`acid` int(11) NOT NULL,
`isdone` bit(1) NOT NULL,
PRIMARY KEY (`ordid`)
)
表:pos_details
CREATE TABLE `orderdet` (
`ordid` int(11) NOT NULL,
`productid` int(11) NOT NULL,
`qty` int(11) NOT NULL
)
和我已经创建了一个表在我的html页面输入产品和它的数量它看起来像这样(https://jsfiddle.net/egpqbzuc/)
直到这一切都很好。现在我需要更新上述表
中的这些条目它像pos_master
更新第一(我已经在我的html中存储了wid,repid,acid,orddate,isdone
的值),第二个表应该从ordid
中相应的条目和我的html表中的值更新到第二个表pos_details
。如何在事务块中做到这一点,以便我可以提交或回滚我的sql任务
如果您正在使用PDO,您可以查看:http://at2.php.net/manual/en/pdo.begintransaction.php。类似的解决方案可以在PHP文档中找到。最后,你也可以使用纯sql:$ db ->查询("开始事务;")https://dev.mysql.com/doc/refman/5.0/en/commit.html