MYSQL operations in php (2) database dql query statements

Source: Internet
Author: User

MYSQL operations in php (2) database dql query statements

 Connect_error) {die ($ mysqli-> connect_error);} // create a pre-compiled object $ SQL = "select id, name, age, qq from table name where id

 prepare($sql);//绑定参数$id=10;//给?处进行赋值,"ssi"指string,string,int,数据类型和顺序一一对应//bind_param()这里参数数目是可变。$mysqli_compile->bind_param("i",$id);//绑定结果集,这里是用引用传参的方式$mysqli_compile->bind_result($name,$age,$qq);//执行语句$res = $mysqli_compile->execute();//失败打印出原因if(!$res){die("失败原因=".$mysqli_compile-error);}//取出绑定结果值while($mysqli_compile->fetch()){echo "--$id--$name--$age--$qq";}//如果还要取其他的结果可以再次绑定参数取结果,但不用绑定结果集//释放结果集$mysqli_compile->free_result();//关闭资源,除去数据库的预编译的指令$mysqli_compile->close();//关闭链接资源$mysqli->close();?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.