Home > Database > Mysql Tutorial > SAE上连接MySQL数据库_MySQL

SAE上连接MySQL数据库_MySQL

WBOY
Release: 2016-05-31 08:48:00
Original
1148 people have browsed it

 在sae上部署自己的代码后,肯定是需要连接到sae 的数据库的,接下来看看如何实现数据库的连接。sae连接数据库已经被模块化, 只需要使用Saemysql类即可实现。

<?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();?>
Copy after login



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template