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,