PHP database calling class invocation instance (verbose comment) _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
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 the database
$conn = $db->config ("Dns=aaa;uid=sa;pwd=sa;dbname=test");
3. Select a database
$dbname = $db->select_db ("test");
4. Set Allow debugging
$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 results
$rs = $db->query ("SELECT * from test01");
7. Display results in row mode
echo "
Display result set in row mode
";
while ($r = $db->fetch_row ($rs)) {
echo $r [0]. ":". $r [1]. "
";
}

8. Display results in array mode
$rs 2 = $db->query ("SELECT * from test01");

echo "
Display 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/325665.html www.bkjia.com true http://www.bkjia.com/PHPjc/325665.html techarticle Copy the code code as follows:? PHP require_once ("mssql.class.php"); 1. Create the class and connect to the database $db = new MSSQL ("Dns=aaa;uid=sa;pwd=sa;dbname=test"); 2. Connect database $conn = ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.