谁来帮我解释一下下面这段代码,是SAE里面php调用MYsql的,谢谢!
<?php$mysql=newSaeMysql();$sql="SELECT*FROM`user`LIMIT10";$data=$mysql->getData($sql)...
<?php
$mysql = new SaeMysql();
$sql = "SELECT * FROM `user` LIMIT 10";
$data = $mysql->getData( $sql );
$name = strip_tags( $_REQUEST['name'] );
$age = intval( $_REQUEST['age'] );
$sql = "INSERT INTO `user` ( `name` , `age` , `regtime` ) VALUES ( '" . $mysql->escape( $name ) . "' , '" . intval( $age ) . "' , NOW() ) ";
$mysql->runSql( $sql );
if( $mysql->errno() != 0 )
{
die( "Error:" . $mysql->errmsg() );
}
$mysql->closeDb();
?> 展开
$mysql = new SaeMysql();
$sql = "SELECT * FROM `user` LIMIT 10";
$data = $mysql->getData( $sql );
$name = strip_tags( $_REQUEST['name'] );
$age = intval( $_REQUEST['age'] );
$sql = "INSERT INTO `user` ( `name` , `age` , `regtime` ) VALUES ( '" . $mysql->escape( $name ) . "' , '" . intval( $age ) . "' , NOW() ) ";
$mysql->runSql( $sql );
if( $mysql->errno() != 0 )
{
die( "Error:" . $mysql->errmsg() );
}
$mysql->closeDb();
?> 展开
3个回答
展开全部
<?php
//初始话mysql连接
$mysql = new SaeMysql();
$sql = "SELECT * FROM `user` LIMIT 10";
//执行sql
$data = $mysql->getData( $sql );
//获取name参数,并过滤掉html xml php标记
$name = strip_tags( $_REQUEST['name'] );
//age参数格式化为整型
$age = intval( $_REQUEST['age'] );
//构造插入语句
$sql = "INSERT INTO `user` ( `name` , `age` , `regtime` ) VALUES ( '" . $mysql->escape( $name ) . "' , '" . intval( $age ) . "' , NOW() ) ";
//执行插入语句
$mysql->runSql( $sql );
//判断执行是否成功
if( $mysql->errno() != 0 )
{
die( "Error:" . $mysql->errmsg() );
}
//关闭数据库连接
$mysql->closeDb();
?>
//初始话mysql连接
$mysql = new SaeMysql();
$sql = "SELECT * FROM `user` LIMIT 10";
//执行sql
$data = $mysql->getData( $sql );
//获取name参数,并过滤掉html xml php标记
$name = strip_tags( $_REQUEST['name'] );
//age参数格式化为整型
$age = intval( $_REQUEST['age'] );
//构造插入语句
$sql = "INSERT INTO `user` ( `name` , `age` , `regtime` ) VALUES ( '" . $mysql->escape( $name ) . "' , '" . intval( $age ) . "' , NOW() ) ";
//执行插入语句
$mysql->runSql( $sql );
//判断执行是否成功
if( $mysql->errno() != 0 )
{
die( "Error:" . $mysql->errmsg() );
}
//关闭数据库连接
$mysql->closeDb();
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询