php+mysql事务处理的几个步骤:
1.关闭自动提交
2.开启事务处理
3.有异常就自动抛出异常提示再回滚
4.开启自动提交
注意:mysql只有这个InnoDB驱动是支持事务处理的,默认MyIsAM驱动不支持.
下面是实例代码:
php+mysql事务处理的几个步骤:
1.关闭自动提交
2.开启事务处理
3.有异常就自动抛出异常提示再回滚
4.开启自动提交
注意:mysql只有这个InnoDB驱动是支持事务处理的,默认MyIsAM驱动不支持.
下面是实例代码:
check_php_syntax.sh
#!/bin/bash
# check php syntax
if [ $# -lt 1 ];then
echo 'Usage: ' $0 'directory';
exit
fi
if [ ! -d $1 ];then
echo $1 'not a directory,please check!';
exit
fi
directory=$1
temp_file="/tmp/file$$"
#echo $temp_file
ls -R $directory | awk '
BEGIN{
FS="n"
folder="'$directory'"
logname="'$temp_file'"
}
{
if($0~/.php$/){
system("php -l " folder "/" $0 " >> " logname " 2>&1")
}
if($0~/:$/){
folder=substr($1,1,length($1)-1)
}
}
'
if [ -e $temp_file ];then
cat $temp_file | awk '
BEGIN{
error = 0
}
{
if($0~/Parse/) {
error++
errorfile[$0] = $0
}
}
END{
print "错误文件:" error "个"
if(length(errorfile)>0) print "错误行数:"
for (i in errorfile)
print i
}
'
else
echo "php file not found."
exit;
fi
<?php
/**
* Tanphp framework
*
*
* @category Tanphp
* @package Data_structure
* @copyright Copyright (c) 2012 谭博 tanbo.name
* @version $Id: Tree.php 25024 2012-11-26 22:22:22 tanbo $
*/
语法
mysql_connect(servername,username,password);
例
print_r(getimagesize('http://www.phprm.com/logo.jpg'));
输出的结果为:
Array
(
[0] => 550
[1] => 190
[2] => 3
[3] => width="550" height="190"
[bits] => 8
[mime] => image/png
)
常量检测使用defined,定义常量则是define。注意待检测的常量需要使用引号(单双均可),如:
if (defined('CONST_NAME')) {
//do something
}
方法一:
<?php
http://pic2.phprm.com/2013/08/23/$url.jpg = “http://www.phprm.com”;
$fileExists = @file_get_contents($url, null, null, -1, 1) ? true : false;
echo $fileExists; //返回1,就说明文件存在。
?>
CJuiAutoComplete 在用户输入时可以根据用户输入的前几个字符自动提示用户可以输入的文字。它封装了 JUI autocomplete插件。
基本用法如下:
取得Response Headers,之后慢慢分析就行了。
给出具体实现方法:
例1
直接把日期转换
//计算年龄
根据年份计算生肖