Copy Code code as follows:
<?php
Require_once "db.php"; Include Class library files
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Connecting to a database
if (! Db::iserror ($conn)) {//To determine whether the connection was successful
Print "Database connection succeeded";
}
Else
{
echo Database connection Failed! ";
}
?>
Copy Code code as follows:
<?php
Require_once "db.php";
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Calling Connect connection Database
if (Db::iserror ($conn))////If the connection is wrong, error
{
Print "Database connection failed";
}
$rs = $conn->query ("Select Id,username, password from tablename1"); Execute SQL statement
if (Db::iserror ($RS))//Determine whether the execution succeeds
{
Print "Data query failed";
}
while ($rs->fetchinto ($rows))//Loop output query Results
{
Print "Number number: $rows [0]<br>";
Print "Name: $rows [1]<br>";
Print "Password: $rows [2]<br>";
print "<HR>";
}
?>
Copy Code code as follows:
<?php
Require_once "db.php";
$conn = Db::connect ("Mysql://root:1981427@localhost/test"); Calling Connect connection Database
if (Db::iserror ($conn))////If the connection is wrong, error
{
Print "Database connection failed";
}
Executes the SQL statement, returning 1 records starting from article No. 0
$rs = $conn->limitquery ("Select Id,username, password from tablename1", 2,5); Query out third to sixth data in a recordset
if (Db::iserror ($RS))////If the query fails, the error occurs
{
Print "Data query failed";
}
while ($rs->fetchinto ($rows))//Loop output query Results
{
Print "Number: $rows [0]<br>";
Print "Name: $rows [1]<br>";
Print "Password: $rows [2]<br>";
print "<HR>";
}
?>
Copy Code code as follows:
<?php
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 succeeded";
}
?>