<?
 
  require("class_mysql.inc.php");
 
  
 
  // opening connection
 
  $mysql=new mysql("test","localhost","test","password_for_test");
 
  
 
  // creating table
 
  $sql="CREATE TABLE `table_test` (
 
`id` BIGINT NOT NULL ,
 
`field1` VARCHAR( 50 ) NOT NULL ,
 
`field2` VARCHAR( 100 ) NOT NULL ,
 
PRIMARY KEY ( `id` ) 
 
);";
 
  $mysql->query($sql);
 
  
 
  // inserting some datas
 
  for ($i=0;$i<5;$i++) { 
 
    $mysql->insert("table_test",array('id','field1','field2'),array("data ".$i,"other data ".$i));
 
    
 
  // display content of table
 
  print_r($mysql->query("SELECT * FROM table_test ORDER BY field1"));
 
  
 
  // an update to the table, for id=3
 
  $mysql->update("table_test",array('field1','field2'),array('aaa','bbb'),"id=3");
 
  
 
  // display a field for id=4, if SELECT return no line, "none" return 
 
  echo $mysql->select_value("SELECT field2 FROM table_test WHERE (id=4)","none");
 
  
 
  // delete a line, for id=2
 
  $mysql->delete("table_test","id=2");
 
  
 
  // display content of table
 
  print_r($mysql->query("SELECT * FROM table_test ORDER BY field1"));
 
  
 
?>
 
 |