Proposal for "DB_DbQuery"

» Metadata » Status
  • Status: Proposed
» Description

DbQuery lets us to act directly over a query as if it were a table in our database. For example:


<?php

// connects to the database
$db = new DbQuery("library_test", "root", "xxx");

// executes an SQL query
$row = $db->query("
select
    b.id as book_id,
    b.title,
    b.created_on,
    b.updated_on,
    a.id as author_id,
    a.name as author
from books as b
left join authors as a on a.id = b.author_id
where b.id = 11");

// updates the record
echo "Saving records ...\n";
$row->set("title", "Code Complete 2");
$row->set("author", "Steve McConnell");
$row->update();

// close the database connection
$db->close();
?>

I'm not completely satisfied with this package and I would like to know your opinion. I think the DbQuery class has too much methods and this is indicative of a poor design. I'm working on it in any case.

» Dependencies » Links
» Timeline » Changelog
  • First Draft: 2013-11-01
  • Proposal: 2014-02-15