A good simple database connection class program, there is a need for PHP MySQL database connection class can refer to this article.
| The code is as follows |
Copy Code |
|
br>!--? PHP
require_once ("mssql.class.php");
//1. Create class and connect to 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. Set Allow Debug
$db->debug = true;
5. Execute a SQL statement that does not return a result
$db->execute ("INSERT INTO test01 (" name) values (' This is a test! ') ");
//$db->exec ("");
//6. Execute a SQL statement that returns a result
$rs = $db->query ("SELECT * from test01");
7. Display the result
Echo
as row to display the result set
"in row mode;
while ($r = $db->fetch_row ($rs)) {
echo $r [0]. ":". $r [1]. "
";
}
//8. Display results as array
$rs 2 = $db->query ("SELECT * from test01");
Echo
Displays the result set
"in array mode;
while ($r = $db->fetch_array ($rs 2)) {
echo $r ["id"]. ":" . $r ["Name"]. "
";
}
//x. Release
$db->db_close ();
?
|
http://www.bkjia.com/PHPjc/632932.html www.bkjia.com true http://www.bkjia.com/PHPjc/632932.html techarticle a good Simple database connection class program, there is a need for PHP MySQL database connection class can refer to this article. Code to copy code as follows? PHP require_once (mssql.class.php); 1. Create a ...