Usage of ADODB in PHP

Source: Internet
Author: User
1 // assume that the database name is a table name B 2 3 // contains the ADODB Class 4 5 include_once ("ADODB. inc. PHP "); 6 7 // connection type of the database -------------------- connection method 1 8 9 $ db = newadoconnection (" MySQL "); 10 11 $ db-> connect (" localhost ", "root", "my123", "A") or die ("link database error "); 12 // ------------------------------------------ connection method 213 // $ db-//> newadoconnection ("MYSQL: // root: my123 @ localhost/B ") 14 // set the character set to 15 16 $ db-> excute ("set names 'utf8 '"); 17 18 // query 19 20 $ query = $ db-> execute ("select * from B"); 21 While ($ ROW = $ query-> fetchrow ()) {22 23 print_r ($ row); 24} 25 26 // insert 27 28 $ arr = array (29 30 'name' => 'one ', 31 'age' => '18', 32 'sex' => 'boys', 33) 34 $ db-> autoexecute ('B', $ arr, 'insert'); // insert upper case 35 36 // Update 37 38 $ SQL = "Update B set name = 'Wo 'Where id = '1 '"; 39 $ db-> execute ($ SQL); 40 41 42 // page 43 44 for ADODB ("ADODB. inc. PHP "); 45 shortde_once (" adodb-page.inc.php "); 46 session_start; // use session to save the page; 47 // link in address mode 48 $ db = newadoconnection (" MYSQL: // root: my123 @ localhost/B "); 49 $ SQL =" select * from B "; 50 $ page = new adodb_pager ($ SQL ); 51 $ page-> reader (3); 52 53 // display 54 55 items de_once ("tohtml. inc. PHP "); 56 $ db = newadoconnection (" MySQL "); 57 $ db-> connect (" localhost ", 'root', 'my123', 'A '); 58 $ query = $ db-> execute ("select * from B"); 59 echo rs2html ($ query );

The above is only a common part,

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.