Example #1
0
 public static function byContentAndType($id, $type)
 {
     if (!array_key_exists($type, self::$types)) {
         $comments = Collection::none();
     } else {
         //look up the comments
         $sql = "SELECT id, user_id\n\t\t\t\tFROM comments\n\t\t\t\tWHERE content_id = ?\n\t\t\t\tAND content_type = ?\n\t\t\t\tORDER BY comment_date ASC\n\t\t\t";
         $comments = new Collection($sql, array($id, $type));
     }
     $comments->bindType('id', 'Comment');
     $comments->bindType('user_id', 'User');
     return $comments;
 }
Example #2
0
 public function test0_Validate()
 {
     $collection = new Collection(new Yaml());
     $collection->merge(static::$collection);
     $collection->thaw('part1');
     $this->assertFalse($collection->immutable('part1'));
     $collection->thaw('*');
     $this->assertFalse($collection->none());
     $this->assertTrue($collection->size() == 1);
     //$collection = new Collection(new Yaml);
     $collection->{'thing'}('boing');
     $this->assertEquals($collection['thing'], 'boing');
     $collection->freeze("*");
     $collection->freeze(['thing']);
 }
Example #3
0
 public static function getMine($all = false)
 {
     if (User::isLoggedIn()) {
         $sql = "SELECT id FROM notifications WHERE id > ? AND (to_user_id = ? or to_user_id IS NULL)";
         $data = array();
         if ($all === false) {
             $data[] = User::$me->get('last_notification');
         } else {
             $data[] = 0;
             // Get all of them
         }
         $data[] = User::$me->id;
         $notifications = new Collection($sql, $data);
         $notifications->bindType('id', 'Notification');
         return $notifications;
     } else {
         // Return empty collection
         return Collection::none();
     }
 }