How to connect to the SAE database .. the last time I split the framework, I needed to connect to the SAE Database. I really didn't set up my own database. crazy sweat. sae gave this sae. class. php class, how can I use this swelling ?............... Define how to connect to an SAE database
Ask... the last time I split the framework, I needed to connect to the SAE Database. I really didn't set up my own database.
Sae gave this sae. class. php class. how can it be swollen ?............... To define the data display, how does one set up another data COM file? Or is it written in this class?
The splitting of the framework is really so tragic. the MVC structure, the entry file, the data com layer, the mod layer, the pageletes layer, the presentation layer, and the modul layer, I have included all of them to the entry file. is this correct? I feel very desperate. I don't know if I should continue to split it, but I should try again later.
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...
PHP code
ArrSql [] = $ SQL; $ result = $ this-> conn-> getData ($ SQL); if ($ this-> conn-> errno ()) spError ("{$ SQL}
Execution error :". $ this-> conn-> error (); return $ result;}/*** return the primary key ID of the currently inserted record */public function newinsertid () {return $ this-> conn-> lastId ();}/*** format the SQL statement with limit */public function setlimit ($ SQL, $ limit) {return $ SQL. "LIMIT {$ limit}";}/*** execute an SQL statement ** @ param SQL the SQL statement to be executed */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;}/*** number of affected rows returned */public function affected_rows () {return FALSE; // The number of affected rows cannot be obtained in the SAE environment.}/*** obtain the 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 ($ dbConfig) {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 */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-> closeDb ();} /*** getConn get Sae MySQL object * to better use Sea to provide MySQL class, the getSeaDB function returns the Sae MySQL object for developers to use */public function getConn () {return $ this-> conn ;}}