Copy CodeThe code is as follows:
Require_once "db.php"; Include Class library files
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Connecting to a database
if (! Db::iserror ($conn)) {//Determine if the connection is successful
Print "Database connection succeeded";
}
Else
{
echo "Database connection failed! ";
}
?>
Copy CodeThe code is as follows:
Require_once "db.php";
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Call the Connect connection database
if (Db::iserror ($conn))//error if connection is faulted
{
Print "Database connection failed";
}
$rs = $conn->query ("Select Id,username, password from tablename1"); Execute SQL statement
if (Db::iserror ($RS))//Determine if execution succeeded
{
Print "Data query failed";
}
while ($rs->fetchinto ($rows))//Loop output query Results
{
Print "No.: $rows [0]
";
Print "Name: $rows [1]
";
Print "Password: $rows [2]
";
Print "";
}
?>
Copy CodeThe code is as follows:
Require_once "db.php";
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Call the Connect connection database
if (Db::iserror ($conn))//error if connection is faulted
{
Print "Database connection failed";
}
Executes the SQL statement and returns 1 records starting with the No. 0 entry
$rs = $conn->limitquery ("Select Id,username, password from tablename1", 2,5); Querying the third to sixth data in a recordset
if (Db::iserror ($RS))//error if query is wrong
{
Print "Data query failed";
}
while ($rs->fetchinto ($rows))//Loop output query Results
{
Print "No.: $rows [0]
";
Print "Name: $rows [1]
";
Print "Password: $rows [2]
";
Print "";
}
?>
Copy CodeThe code is as follows:
Require_once "db.php";
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Connecting to a database
if (Db::iserror ($conn))
{
Print "Database connection failed";
}
Preparing SQL statements using the Prepare function
$rs = $conn->prepare ("update tablename1 Set password = ' Susan ' WHERE id = ' 1 '");
if (Db::iserror ($RS))
{
Print "Data update failed";
}
Else
{
$conn->execute ($RS); Execute SQL Statement Update database
Print "Data update success";
}
?>
http://www.bkjia.com/PHPjc/319873.html www.bkjia.com true http://www.bkjia.com/PHPjc/319873.html techarticle Copy the code as follows: PHP require_once "db.php";//contains class library file $conn = Db::connect ("Mysql://root:1981427@localhost/test");//Connect to Database if (! Db::iserror ($conn)) {...