Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

53 lines (45 sloc) 1.666 kb
<?php
header("Content-type: text/plain; charset=UTF-8");
require_once "classes/autoload.php";
use com\soloproyectos\common\db\DbConnector;
use com\soloproyectos\common\db\DbDataSource;
use com\soloproyectos\common\db\DbTable;
$db = new DbConnector("database", "username", "password");
// updates the record "content.id = 101"
$t = new DbTable($db, "content", 101);
$t->set("description", "Record description...");
$t->set("image.path", "/path/to/image.jpg");
$t->set("video.path", "/path/to/video.mp4");
$t->set("file.path", "/path/to/file.pdf");
$t->update();
// inserts a new record
$t = new DbTable($db, "content");
$t->set("description", "Record description...");
$t->set("image.path", "/path/to/image.jpg");
$t->set("video.path", "/path/to/video.mp4");
$t->set("file.path", "/path/to/file.pdf");
$t->insert();
// deletes the record "content.id = 101"
$t = new DbTable($db, "content", 101);
$t->delete();
// prints info from the record "content.id = 101"
$t = new DbTable($db, "content", 101);
$t->get("description");
$t->get("image.path");
$t->get("video.path");
$t->get("file.path");
// loops through the records of the table "content"
$t = new DbTable($db, "content");
$t->setOrder("id desc");
$t->setFilter("section_id = 'blah'");
foreach ($t as $row) {
// updates the record
$row->set("description", "New description");
$row->set("image.path", "/path/to/new/image.jpg");
$row->update();
// prints some info
echo "Description: " . $row->get("description") . "\n";
echo "Image: " . $row->get("image.path") . "\n";
echo "Video: " . $row->get("video.path") . "\n";
echo "File: " . $row->get("file.path") . "\n";
}
Jump to Line
Something went wrong with that request. Please try again.