JimL
-
Posts
5 -
Joined
-
Last visited
Posts posted by JimL
-
-
AR is just a pattern. One of the more popular frameworks getting around these days (Laravel) uses this same pattern for its ORM Eloquent. So, the pattern is around, I've just never heard of that particular library before.
AR isn't a particularly good pattern to use for an ORM anyway though in my opinion as it tightly couples you models to their persistence implementation. The Data Mapper pattern gives you a much cleaner end result. Maybe you'd be interested in looking at that? If so, I would highly recommend Doctrine.
Yeah PHP-AR is being used in a project at work, so was trying to get my head around it.
For other projects at home I'm using Doctrine2
Thanks!
-
I'm not sure you're going to find much help here with such an obscure little library.
Yeah, guessing it's bigger in ruby than in php.
-
It's from a hobby project I'm working on using Active Record. An Object Relational Mapper (ORM) which basically is an abstraction layer for database interaction.I have no idea what you are showing us.
-
1
Total number of likes work, but I'm guessing it can be done differently, any input would be appreciated.
/controllers/indexController.php$posts = Post::find('all', [ 'limit' => 4, 'include' => ['likes'] ]); foreach ($posts as $post) { $post->assign_attribute('likeCount', count($post->likes)); } }
/models/Post.phpclass Post extends ActiveRecord\Model { static $has_many = [ ['comments', 'class_name' => 'PostComments'], ['likes', 'class_name' => 'UserLikePosts'] ]; }
/models/UserLikePosts.phpclass UserLikePosts extends ActiveRecord\Model { static $belongs_to = [ ['user'], ['post'] ]; }
2
The big question is, how can I get a true/false for "if current user has liked post"? I was thinking something like this, but using vars won't work here, and I would have to use a ternary or a function call to do it like this as the session var might not be set (guest).
class Post extends ActiveRecord\Model { static $has_many = [ ['comments'], ['likes', 'class_name' => 'UserLikePosts'], ['user_likes', 'class_name' => 'UserLikePosts', 'conditions' => ['user_id = ?', [$_SESSION['user']['id']]] ]; }
Security Issues related to Apache servers and PHP
in Apache HTTP Server
Posted
Have a look at this as a decent writeup on how to isolate vhosts.
http://tushev.org/articles/linux-bsd/item/53-setting-up-your-multi-user-hosting-vps-server-apache-a-secure-way-to-run-several-joomla-worpress-drupal-sites