<?php
/*
********************************************************
Name: addCar.php
Author: Rob Hunter
Date 1/14/11
Description: This is file shows how to add content to the database.
********************************************************
*/
//require the init file
require_once('../lib/initHunterDB.php');
//create the content: new HDB_Content( $title, $type, $description )
$myCar = new HDB_Content( 'Honda Element',
'Car',
""
);
//set my attributes
$myCar->my->make = "Honda";
$myCar->my->model = "Element";
$myCar->my->year = 2006;
$myCar->my->color = "Lime Green";
?>
CODE<BR>
$myCar = new HDB_Content( 'Honda Element',
'Car',
""
);<br><br>
$myCar->my->make = "Honda";<br>
$myCar->my->model = "Element";<br>
$myCar->my->year = 2006;<br>
$myCar->my->color = "Lime Green";<br>
$myCar->save();<br><br><Br>
<?php
//save content (adds content to database)
$myCar->save();
//output some stuff to see what you did
echo "Query Run <br><br><br>";
//query for all objects of this type
$query = new HDB_Query();
$query->filter('type','=','Car');
$results = $query->execute();
//iterate over results, using ->debugHTML() to see what's going on
if (!empty($results)){
foreach ($results as $result){
print $result->debugHTML();
}
}
else{
echo 'No results<br><br>';
}
/*
Copyright 2011 Oversee.net. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY OVERSEE.NET ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OVERSEE.NET OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Oversee.net.
*/
?>