php mysql回滚示例
首先,建InnoDB类型的表,才能支持事务
$handler = mysql_connect('localhost', '', '');
mysql_select_db('test');
mysql_query('SET AUTOCOMMIT=0'); // 设置为不自动提交查询
mysql_query('START TRANSACTION'); // 开始查询,这里也可以使用BEGIN
mysql_query("INSERT INTO users VALUES ('ccc')");
mysql_query("DELETE from users WHERE username = 'aac'");
if (mysql_affected_rows($handler) == 0)
mysql_query('ROLLBACK'); // 如果删除未找到相应的记录则回滚,不执行上面的插入查询
mysql_query('COMMIT');
mysql_close($handler);
相关文档:
Php Variable Circular References
Circular-references has been a long outstanding issue with PHP. They are
caused by the fact that PHP uses a reference counted memory allocation
mechanism for its internal variables. This causes problems for longer
running scripts (such as an Applicatio ......
整理活:PHP的日期时间函数date()
1,年-月-日
echo date('Y-m-j');
2007-02-6
echo date('y-n-j');
07-2-6
大写Y表示年四位数字,而小写y表示年的两位数字;
小写m表示月份的数字(带前导),而小写n则表示不带前导的月份数字。
echo date('Y-M-j');
2007-Feb-6
echo date('Y-m-d');
2007-02-06
大写M表示月份的 ......
PayPal 快速、安全而又方便,是跨国交易的首选在线付款方式。现在PayPal可以和国内大部分信用卡关联,可以实现国人的跨国交易收支。
申请PayPal注册网址:https://www.paypal.com/
paypal接口与其它接口有些不同,稍微复杂一点。 其实银行接口也算是一个站点的插件。
所谓paypal ipn(Instant Payment Notification),就 ......
原型:string substr ( string $string , int $start [, int $length ] ),它可以用于在一个较长的字符串中查找匹配的字符串或字符。$string为所要处理的字符串,$start为开始选取的位置,$length为要选取的长度(当它是负数时为负数时表示右起数起的位置)。
例:
<?php
$rest1 = substr("abcdef", 0, 0); // returns ......
客户用的数据库是mysql,而研发好的产品支持oracle,为了让客户掏腰包,我们必须把数据库环境从oracle转向mysql。我们在转换的过程中碰到了下面一些问题,希望能给同样遭遇的同仁们一些借鉴。如果我们在最初的设计、编码过程中注意数据库的移植性,这种情况下可以完全不需要作额外工作。
一、数据库环境从oracle转 ......