I'm building a Help Desk application, and was wanting some experienced advice.
As I populate my data in a ticket from a database connection object, would it be better to send one large query retreiving all the data, and then extracting it out to my fields, or should I send many smaller queries each getting data for it's own field.
In other words:
THIS:
Class Ticket extends Request {
$db = new DB;
.......
function getData {
$db->query("SELECT * FROM table1, table2, table3 WHERE id = $id" AND status = $status .....etc");
$db->extract_Data()
}
}
OR THIS:
Class Ticket extends Request {
$db = new DB;
........
function getStatus () {
$db->query("SELECT status FROM table1 WHERE id = $id");
}
function getCreated ();
function getResolution();
........
}
$ticket = new Ticket;
$ticket ->setID($id)
echo ("STATUS: " . $ticket->getStatus());
echo ("CREATED: " . $ticket->getCreated());
........
I have about 2000 users on my network, and want an efficient way to connect to my DB server without hammering it, but, at the same time, would like to code my application efficiently as well.
I sure hope this made sense. I am not much of a PHP programmer, and would very much like some advice here.
TIA!