简体   繁体   中英

What is the mysqli equivalent for this mysql_result statement?

This is the code I was using with mysql and now I am trying to convert all of my functions over to mysqli. How would I format this so that it returns the values I need?

return (mysql_result($query, 0) == 1) ? true : false;

mysqli has a main function "query" If it's CRUD SQL it will return 1 or 0 (success or not) if it's select SQL it will return the result

$sqli = new mysqli(DB_SERVER,
                            DB_USERNAME,
                            DB_PASSWORD,
                            DB_NAME);
$result = $sqli->query("INSERT INTO...");
return ($result == 1) ? true : false;

我只会使用return ($mysqli->query($query) == 1)但这只是我,我相信你可以为一个布尔值返回值

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM