<?
include('SimpleSQL.class.php');
$mysql=new SimpleSQL("test_db"); // most of the connection vars are in the class file
// you CAN provide the connection vars, but they are optional
// view class file for more info
$mysql->db_table="content"; // assign "content" to the active table
$mysql->debug=true; // enable debug mode (prints out the class file's every move)
/***************************************\
The following code assumes your database
is set up like this:
database name: test_db
table name: content
fields: location,content (both type text)
\***************************************/
$stuff="<html>
<body>
<h3>w00t</h3>
</body>
</html>";
// insert stuff into the database
$mysql->insert("'location','content'","'home','$stuff'","content"); // ("content" is really optional,
// the script already has it stored
// in a public variable (view up top)
// insert function works like this:
// first argument are the fields
// second arguemnt is the data
// third and on are optional (see comments in class file)
$mysql->get_content("content","WHERE location='home'");
echo "Number of Rows: ".$mysql->num_rows();
echo"<pre>";
print_r($mysql->result); // this will be an array
echo"</pre>";
// optional arguments [db_table],[db_order],[db_limit] for delete
$mysql->delete("WHERE location='home'","","",1); // delete rows and limit to 1
for($i=0;$i<4;$i++) // loop and insert
$mysql->insert("'location','content'","'services','im on the services page'");
// another example of insert function
$mysql->get_content("","WHERE location='services'");
echo"<pre>";
print_r($mysql->result); // this will be an array
echo"</pre>";
// update arguments are: field, newdata, table_name, where, limit
$mysql->update("content","im a newer version of home content","","WHERE location='home'");
// example of the update function
$mysql->get_content();
echo "Number of Rows: ".$mysql->num_rows();
echo"<pre>";
print_r($mysql->result); // this will be an array
echo"</pre>";
echo $mysql->error; // echo errors if any were filled out
?>
|