Why can't I get the return value in the following ways? This post is finally edited by u010416883 from 2013-06-011:37:22! Public static function query ($ SQL, $ unbuffered false?
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}
------ Solution --------------------
What do you get?
------ Solution --------------------
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.
------ Solution --------------------
Public function query ($ SQL, $ unbuffered = false) {...
Either query returns resources or query returns logical values.
------ Solution --------------------
What is the SQL statement you run? What is $ unbuffered during query execution?
------ Solution --------------------
You use elseif. if a condition breaks the following program, it will not go any more.
The above is to ask why the following method cannot get the returned value. For more information, see PHP Chinese website (www.php1.cn )!