Why can't I get the return value in the following ways? This post was last edited by u010416883 at 11:37:22
Answer the following questions!
Public static function query ($ SQL, $ unbuffered = false) {$ ret = self: $ db-> query ($ SQL, $ unbuffered ); // when the sentence is successful, $ ret is 1 Note: self ::$ db-> query is mysql_query if ($ unbuffered === true) {$ cmd = trim (strtoupper (substr ($ SQL, 0, strpos ($ SQL, ''); if ($ cmd = 'select ') {} elseif ($ cmd = 'update' | $ cmd = 'delete') {$ ret = self: $ db-> affected_rows ();} elseif ($ cmd = 'insert') {$ ret = self: $ db-> insert_id (); // it indicates that the task is executed, returned int type idnumber} return $ ret; // The final return is not an int type idnumber}
Reply to discussion (solution)
What do you get?
Empty string !!!!!
No matter whether there are any subsequent operations, at least $ ret = self: $ db-> query ($ SQL, $ unbuffered); is returned.
If yes, $ ret is 1 when the sentence is successful, and you say the return is null, it is obviously a query failure.
$ Ret = self: $ db-> query ($ SQL, $ unbuffered); this returns 1, and the database data is inserted normally,
In addition, the following judgment also returns the inserted id through echo, but the final return returns an empty string.
Supplemental Procedures
Self: $ db-> query ($ SQL, $ unbuffered); the public function query ($ SQL, $ unbuffered = false) {$ func = $ unbuffered? 'MySQL _ unbuffered_query ': 'MySQL _ query'; $ query = $ func ($ SQL, $ this-> curlink); $ this-> querynum ++; return $ query;} self: $ db-> insert_id (); function insert_id () {return ($ id = mysql_insert_id ($ this-> curlink)> = 0? $ Id: @ mysql_result ($ this-> query ("SELECT last_insert_id ()"), false );}
Public function query ($ SQL, $ unbuffered = false) {...
Either query returns resources or query returns logical values.
What is the SQL statement you run? What is $ unbuffered during query execution?
Public function query ($ SQL, $ unbuffered = false) {...
Either query returns resources or query returns logical values.
This is $ ret = self: $ db-> query ($ SQL, $ unbuffered );
The return value echo is 1, indicating that the SQL is successfully executed!
You use elseif. if a condition breaks the following program, it will not go any more.