MySQLi - Options

语法

bool mysqli_options ( mysqli $link , int $option , mixed $value )

定义和用法

它用于设置选项。

示例

试试下面的例子 −

<?php
   $servername = "localhost:3306";
   $username = "root";
   $password = "";
   $dbname = "TUTORIALS";
   $conn = new mysqli($servername, $username, $password, $dbname);

   if ($conn->connect_error) {
      die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
      exit();
   } 
   if (!mysqli_query($conn, "SET a = 1")) {
      printf("Errorcode: %d
", mysqli_error($conn));
   }
   mysqli_options($conn,MYSQLI_READ_DEFAULT_FILE,"filefile.cnf");
   echo 'Success... ' . mysqli_get_host_info($conn) . "
";
   
   $sql = "SELECT * FROM tutorials_auto";
   if ($conn->multi_query($sql)) {
      do {
         /* store first result set */
         if ($result = $conn->store_result()) {
            while ($row = $result->fetch_row()) {
                printf("%s
", $row[1]);
            }
            $result->free();
         }
         if ($conn->more_results()) {
         }
      } while ($conn->next_result());
   }
   $conn->close();
?>

上述代码的示例输出应该是这样的 −

Errorcode: 0 Success... localhost:3306 via TCP/IP sai ram sai

mysqli_useful_functions.html