怎样连接SAE的数据库
求问..还是上次拆框架那个事,需要连接SAE的数据库,真心没自己设过数据库阿.狂汗.
sae那里就给了这个sae.class.php类, 该肿么用?...............定义数据显示是要另立一个数据COM文件呢?还是就写在这个类里?
拆框架真心太悲剧乐, MVC结构,入口文件->数据com层->mod层->pageletes层->表现层->modul层,一层套一层, 我全部给include到入口文件里了,这样写对不对?感觉很绝望. 不知道该进继续拆好,还是退一步重新使用框架好.
Sae Mysql Class
$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();
?>
------解决方案--------------------
再来一个...嘿嘿
- PHP code
<?php ///////////////////////////////////////////////////////////////// // SpeedPHP中文PHP框架, Copyright (C) 2008 - 2010 SpeedPHP.com // ///////////////////////////////////////////////////////////////// /** * SAE中MySQL数据库的驱动支持 * * SAE是Sina App Engine(新浪应用引擎)的缩写,SAE是一个分布式web应用开发运行的服务平台, * 其不仅仅包含创建、部署web应用的简单交互,更涉及一整套大规模分布式服务的解决方案。 * * db_sae 封装了SAE提供的SaeMysql类的驱动操作。 */ class db_sae { /** * 数据库链接句柄 */ public $conn; /** * 执行的SQL语句记录 */ public $arrSql; /** * 按SQL语句获取记录结果,返回数组 * * @param sql 执行的SQL语句 */ public function getArray($sql) { $this->arrSql[] = $sql; $result = $this->conn->getData($sql); if( $this->conn->errno() )spError("{$sql}<br>执行错误: " . $this->conn->error()); return $result; } /** * 返回当前插入记录的主键ID */ public function newinsertid() { return $this->conn->lastId(); } /** * 格式化带limit的SQL语句 */ public function setlimit($sql, $limit) { return $sql. " LIMIT {$limit}"; } /** * 执行一个SQL语句 * * @param sql 需要执行的SQL语句 */ public function exec($sql) { $this->arrSql[] = $sql; $result = $this->conn->runSql($sql); if( $this->conn->errno() )spError("{$sql}<br>执行错误: " . $this->conn->error()); return $result; } /** * 返回影响行数 */ public function affected_rows() { return FALSE; // SAE环境暂时无法获取影响行数 } /** * 获取数据表结构 * * @param tbl_name 表名称 */ public function getTable($tbl_name) { return $this->getArray("DESCRIBE {$tbl_name}"); } /** * 构造函数 * * @param dbConfig 数据库配置 */ public function __construct($dbConfig) { if(TRUE == SP_DEBUG)sae_set_display_errors(TRUE); $this->conn = new SaeMysql(); if( $this->conn->errno() )spError("数据库链接错误 : " . $this->conn->error()); $this->conn->setCharset("UTF8"); } /** * 对特殊字符进行过滤 * * @param value 值 */ public function __val_escape($value, $quotes = FALSE) { if(is_null($value))return 'NULL'; if(is_bool($value))return $value ? 1 : 0; if(is_int($value))return (int)$value; if(is_float($value))return (float)$value; if(@get_magic_quotes_gpc())$value = stripslashes($value); return '\''.$this->conn->escape($value).'\''; } /** * 析构函数 */ public function __destruct() { @$this->conn->closeDb(); } /** * getConn 取得Sae MySQL对象 * 为了更好地使用Sea提供MySQL类,getSeaDB函数将返回Sae MySQL对象供开发者使用 */ public function getConn() { return $this->conn; } } <div class="clear"> </div>

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool