public static function selectActiveFriends($props)
 {
     global $config;
     $al = new AL($config['database']);
     $sql = "SELECT * FROM `users` LEFT JOIN `relationship` ON (users.u_id=relationship.u_id1 OR users.u_id=relationship.u_id2)\n            WHERE r_status='FRIENDS' AND u_is_frozen_account != 1 AND u_id!= ? AND (u_id1= ? OR u_id2 = ?) ORDER BY  `u_nickname` {$props['order_by']}";
     $userFriends = $al->query($sql, [$props['id'], $props['id'], $props['id']]);
     if (!$userFriends) {
         return array();
     }
     return $userFriends;
 }
 public static function selectAll($id)
 {
     global $config;
     $al = new AL($config['database']);
     $sql = "SELECT * FROM `posts` WHERE u_id= ? ORDER BY p_date DESC";
     $posts = $al->query($sql, [$id]);
     if (!$posts) {
         return array();
     }
     return $posts;
 }
 public static function allDeclines($id)
 {
     global $config;
     $al = new AL($config['database']);
     $sql = "SELECT * FROM  `users` LEFT JOIN `relationship` ON users.u_id=relationship.u_id2 WHERE r_status='DECLINED' AND u_is_frozen_account != 1 AND u_id1= ? ";
     $declines = $al->query($sql, [$id]);
     if (!$declines) {
         return array();
     }
     return $declines;
 }
 /**
  * @param string $table
  * @param number $id
  * @return Post|Relationship|User
  */
 public static function getRecord($table, $id)
 {
     global $config;
     $al = new AL($config['database']);
     $record = $al->select_one($table, $id);
     switch ($table) {
         case 'users':
             return new User($record);
             break;
         case 'posts':
             return new Post($record);
             break;
         case 'relationship':
             return new Relationship($record);
             break;
     }
     return false;
 }