Phpdaodb insert, update, and delete data _ PHP Tutorial

Source: Internet
Author: User
Phpdaodb inserts, updates, and deletes data. Copy the code as follows :? Phpinclude (adodbadodb. inc. php); contains the adodb class library file $ connNewADOConnection (mysql); connects to the database $ conn-Connect (localhost, root, The code is as follows:


Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('mysql'); // connect to the database
$ Conn-> Connect ('localhost', 'root', '123', 'test ');
$ Conn-> Execute ("insert into tablename1 values ('9', 'zhuzhao', 'Simon ')"); // Execute SQL
?>


The code is as follows:


Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('mysql'); // creates an adodb object and declares that the database type is mysql.
$ Conn-> Connect ("localhost", "root", "1981427", "test"); // Connect to the database, where mydb is the database name
$ Sqle = $ conn-> Execute ("insert into tablename1 values ('10', 'zhuzhao', 'Simon ')"); // use $ sqle to determine whether SQL execution is successful
If ($ sqle) // if the execution succeeds, the execution succeeds.
{
Echo "SQL execution successful ";
}
Else // if the execution fails, the error message is output.
{
Echo $ conn-> ErrorMsg ();
}
?>


The code is as follows:


Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('mysql'); // creates an adodb object and declares that the database type is mysql.
$ Conn-> Connect ("localhost", "root", "1981427", "test"); // Connect to the database, where mydb is the database name
$ Rs = $ conn-> Execute ("SELECT * FROM tablename1"); // Execute the SQL statement and save the result in the result set
If ($ rs) // if execution is successful, information about successful execution of the statement is output.
{
Echo "statement execution successful ";
}
Else // if the execution fails, the error message is output.
{
Echo $ conn-> ErrorMsg ();
}
?>


The code is as follows:


Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('mysql'); // creates an adodb object and declares that the database type is mysql.
$ Conn-> Connect ("localhost", "root", "1981427", "test"); // Connect to the database, where mydb is the database name
$ Rs = $ conn-> Execute ("SELECT * FROM tablename1"); // Execute the SQL statement and save the result in the result set
If ($ rs) // if the execution is successful, the result set is read cyclically.
{
While (! $ Rs-> EOF) // read all records in $ rs cyclically
{
Echo $ rs-> fields [0]. ''. $ rs-> fields [1].''. $ rs-> fields [2].'
'; // Output the current row
$ Rs-> MoveNext (); // move the pointer to the next record
}
}
Else // if the execution fails, the error message is output.
{
Echo $ conn-> ErrorMsg ();
}
?>


The code is as follows:


Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('mysql'); // creates an adodb object and declares that the database type is mysql.
$ Conn-> Connect ("localhost", "root", "1981427", "test"); // Connect to the database, where mydb is the database name
$ Rs = $ conn-> Execute ("SELECT * FROM tablename1"); // Execute the SQL statement and save the result in the result set
If ($ rs) // if the execution is successful, the result set is read cyclically.
{
While (! $ Rs-> EOF) // read all records in $ rs cyclically
{
Echo $ rs-> fields ['id']. ''. $ rs-> fields ['username']. ''. $ rs-> fields ['password'].'
'; // Output the current row
$ Rs-> MoveNext (); // move the pointer to the next record
}
}
Else // if the execution fails, the error message is output.
{
Echo $ conn-> ErrorMsg ();
}
?>

The http://www.bkjia.com/PHPjc/320050.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320050.htmlTechArticle code is as follows :? Php include ("adodb/adodb. inc. php "); // contains the adodb class library file $ conn = NewADOConnection ('mysql'); // connects to the database $ conn-Connect ('localhost', 'root ',...

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.