I designed the site locally in PHP 5, but ran into several design problems that I would like to get right now.
There are currently three site functions, and each function has a class. These functions are as follows:
- the blog
- Friend list
- image set
I have a class for everyone, but in each class I basically define a similar method that everyone gets [blogs | Friends | images]. I was wondering if any of you know how I can reduce these classes to be much thinner and probably have one class that is common to all three functions for all methods that are the same for each function. (i.e. getAllById ($ feature, $ id)).
An example function for my existing blog class is as follows:
function getBlogsByUserId($userId) {
global $db;
$blogs = array();
$db->where(array("userId"=>$userId));
$rows = $db->get("blog")->fetch(0);
foreach($rows as $row) {
$blog = new Blog();
$blog->id = $row['id'];
$blog->userId = $row['userId'];
$blog->content = $row['content'];
$blogs[] = $blog;
}
return $blogs;
}
. , .
, .
, , , , .
,
Matt