Super-quick example of how to use PHPOF2 ---------------------------------------- mysql> create table widgets(id int unsigned primary key auto_increment, name varchar(20) not null, description text, image blob, image_mime_type varchar(20)); common.php (or whatever): widgets.model.php: createRowObject(); $widget->name = 'foo'; $widget->description = "Some long text\nwith a newline"; // Store in database (this inserts if no primary key is set, otherwise updates. // If you need to explicitly insert or update, use PHPOF2_DBRow::insert() or // PHPOF2_DBRow::update()). $widget->store(); // will contain the ID of the newly-inserted row (1 for the first row) echo $widget->id; // Store some binary data. See the top of DBRow.class.php for more documentation $widget_image = file_get_contents('something.jpg'); $widget->storeLOBData($widget_image, 'image'); // get the contents of row ID 1 into a fresh object // this is a shortcut for: // $another_widget = new Widget($widgets); // $another_widget->get(1); $another_widget = new Widget($widgets, 1); // see if there is an image in the database if ($another_widget->image == PHPOF2_DB::LOB_PLACEHOLDER) { // this is how you get binary data back out $my_data = $another_widget->getLOBData('image'); } // simple search "where name=bar" // $my_result will be a PHPOF2_DBResult object $my_result = $widgets->basicSearch('name','bar'); // iterate over result set while ($my_result->fetchIntoObject($another_widget)) { print_r($another_widget); } // Simple LIKE search $my_result = $widgets->basicSearchLike('name','%bar%'); // search the table using arbitrary query $my_result = $DB->query("SELECT * FROM widgets WHERE name LIKE '%foo%' AND description LIKE '%bar%'"); // Remove row $widget->id from the database $widget->delete();