Jump to content

JimL

New Members
  • Posts

    5
  • Joined

  • Last visited

JimL's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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
  2. 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!
  3. 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. http://www.phpactiverecord.org
  4. 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.php class Post extends ActiveRecord\Model { static $has_many = [ ['comments', 'class_name' => 'PostComments'], ['likes', 'class_name' => 'UserLikePosts'] ]; } /models/UserLikePosts.php class 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']]] ]; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.