将 MySQLli 连接对象转换为连接字符串


converting mysqli connection object to connection string

我们可以将mysqli连接对象转换为字符串连接吗?

$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

我们可以为程序查询转换$mysqli 或者这是不可能的。

$query = "SELECT * FROM City ORDER by ID DESC ";
if ($result = mysqli_query($mysqli, $query)) {
    /* fetch associative array */
    while ($obj = mysqli_fetch_object($result)) {
        printf ("%s (%s)'n", $obj->Name;
    }

您可以将 mysqli 与过程风格一起使用,因为它同时支持面向对象的接口、扩展和过程接口。

看到这里