The PHP database invocation class calls the instance of verbose annotation

  • 2020-05-17 05:01:50
  • OfStack


<?PHP 
require_once("mssql.class.php"); 
//1. Create a class , And connect to the database  
$db = new mssql("dns=aaa;uid=sa;pwd=sa;dbname=test"); 
//2. Connect to database  
$conn = $db->config("dns=aaa;uid=sa;pwd=sa;dbname=test"); 
//3. Select database  
$dbname = $db->select_db("test"); 
//4. Settings to allow debugging  
$db->debug = true; 
//5. perform 1 Bar does not return the result SQL statements  
$db->execute("insert into test01(name) values(' This is a 1 A test !')"); 
//$db->exec(""); 
//6. perform 1 Returns the result SQL statements  
$rs = $db->query("select * from test01"); 
//7. In order to row Mode display results  
echo "<br> In order to row Displays the result set <br>"; 
while($r = $db->fetch_row($rs)){ 
echo $r[0].":".$r[1]."<br>"; 
} 

//8. In order to array Mode display results  
$rs2 = $db->query("select * from test01"); 

echo "<br> In order to array Displays the result set <br>"; 
while($r = $db->fetch_array($rs2)){ 
echo $r["id"] . ":" . $r["name"] . "<br>"; 
} 

//X. The release of  
$db->db_close(); 

?> 

Related articles: