How to connect the SAE database solution

Source: Internet
Author: User
How to connect the SAE database
Ask: Or the last time to dismantle the framework, the need to connect to the SAE database, really did not set up a database. Kuanghan.

SAE has given this sae.class.php class, the swelling is used?............... Is the definition data displayed to be a separate data com file? Or is it written in this class?

Torn frame really too tragic music, MVC structure, import file--data COM layer->mod layer->pageletes layer, the performance layer->modul layer, a layer of one layer, I gave the include to the import file, so write right? Feeling very desperate. Do not know whether to continue the demolition, or to step back to use the framework good.


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

------Solution--------------------
Another one ... Hey

PHP Code
  Arrsql[] = $sql;                $result = $this->conn->getdata ($sql); if ($this->conn->errno ()) Sperror ("{$sql}
Execution error: ". $this->conn->error ()); return $result; /** * Returns the primary key ID of the currently inserted record */Public function Newinsertid () {retur n $this->conn->lastid (); /** * Format SQL statement with limit */Public function setlimit ($sql, $limit) { Return $sql. "LIMIT {$limit}"; }/** * Executes an SQL statement * * @param SQL statement required to execute */Public function exec ($sql) {$this->arrsql[] = $sql; $result = $this->conn->runsql ($sql); if ($this->conn->errno ()) Sperror ("{$sql}
Execution error: ". $this->conn->error ()); return $result; }/** * Returns the number of rows affected */Public Function affected_rows () {return FAL SE; SAE Environment temporarily unable to get affected rows}/** * Get data table structure * * @param tbl_name Table name */public function getTable ($tbl _name) {return $this->getarray ("DESCRIBE {$tbl _name}"); }/** * Constructor * * @param dbconfig Database configuration */Public function __construct ($dbCo Nfig) {if (true = = Sp_debug) sae_set_display_errors (true); $this->conn = new Saemysql (); if ($this->conn->errno ()) sperror ("Database link Error:".) $this->conn->error ()); $this->conn->setcharset ("UTF8"); }/** * Filter special characters * * @param value values */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). ' \''; }/** * destructor/Public Function __destruct () {@ $this->conn->clo Sedb (); }/** * Getconn get SAE MySQL Object * In order to better use sea to provide MySQL class, getseadb function will return SAE MySQL object for developers to use * /Public Function Getconn () {return $this->conn; }}
  • 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.