Hi I have the following problem with listing data from DB. Suppose we have table "client" in DB with fields:
id_client username password last_login
query is:
SELECT username,password,last_login FROM client ORDER BY id_client LIMIT 20,20
Normal procedural listing of clients would be:
/* connect to DB using mysqli */
if ($result = $mysqli->query("SELECT username,password,last_login FROM client ORDER BY id_client LIMIT 20,20"))
{
while ($row = $result->fetch_row()) {
printf (" -- %s (%s) -- ", $row[0], $row[1]);
}
$result->close();
}
But I want to impement it using desing pattern and my initial code would be:
class client
{
private id_client,
username,
password,
last_login,
...
}
How to implement client class (and other classes) to perform query request for whole set of clients (not one by one) and list them with one shot(one query) using design patterns? Which pattern should I use?
Greetings