Ejemplo n.º 1
0
 public static function getAppFor($jobId, $page, $limit)
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM applications WHERE jobID = :id ORDER BY id DESC";
     $pager = new OKPager($sql, $limit);
     $pager->conn = $conn;
     $params = array(':id' => $jobId);
     $totalRows = $pager->countTotalRows($params);
     $resultSet = $pager->fetchData($page, $params);
     $rs = array();
     $rs['num_rows'] = $totalRows;
     foreach ($resultSet as $result) {
         $rs['result'][] = $result;
     }
     return $rs;
 }
Ejemplo n.º 2
0
Archivo: Job.php Proyecto: idoqo/yedoe
 public static function archives($page = 1, $limit = 15)
 {
     $conn = new PDO(DB_DSN, DB_USER, DB_PASS);
     $sql = "SELECT * FROM jobs WHERE emp_deleted = '0' AND status = '1' ORDER BY jobID DESC";
     try {
         $pager = new OKPager($sql);
         $pager->conn = $conn;
         $totalRows = $pager->countTotalRows();
         $resultSet = $pager->fetchData($page);
         $rs = array();
         $rs['num_rows'] = $totalRows;
         foreach ($resultSet as $result) {
             $rs['result'][] = new Job($result);
         }
         return $rs;
     } catch (PDOException $e) {
         return $e->getMessage();
     } catch (Exception $E) {
         return $E->getMessage();
     }
 }
Ejemplo n.º 3
0
 public static function archives($page = 1, $limit = 10)
 {
     $conn = new PDO(DB_DSN, DB_USER, DB_PASS);
     $sql = "SELECT * FROM userlist WHERE utype = 'student' ORDER BY userID DESC";
     try {
         $pp = new OKPager($sql, $limit);
         $pp->conn = $conn;
         $totalRows = $pp->countTotalRows();
         $matches = array();
         $matches['num_rows'] = $totalRows;
         foreach ($pp->fetchData($page) as $res) {
             $matches['result'][] = new Student($res);
         }
         return $matches;
     } catch (PDOException $e) {
         //Log this Bit...CH
         return "Error while Searching Users: " . $e->getMessage();
     }
 }
Ejemplo n.º 4
0
 /**
  * Returns an array of all conversations involving the user with $ID
  * Using the receiver index returned, the corresponding user info should
  * be obtained from the users table.
  * @param $id int
  * @param $page int
  * @return array|string
  */
 public static function getChatHeads($id, $page = 1)
 {
     $conn = new PDO(DB_DSN, DB_USER, DB_PASS);
     //this query gotta be bad ass!!!
     $sql = "SELECT messages.sender, messages.receiver, messages.message FROM\n                (SELECT MAX(msg_id) AS msg_id\n                FROM messages\n                WHERE :id IN (sender, receiver)\n                GROUP BY IF(:id = sender, receiver,sender)) AS latest\n                LEFT JOIN messages USING (msg_id) ORDER BY msg_id DESC ";
     try {
         /*$st = $conn->prepare($sql);
           $st->bindParam(":id", $id);
           if(!$st->execute()){
               //log and return false
               return $st->errorInfo();
               //return false;
           }
           else {
               $res = array();
               while ($rows = $st->fetch(PDO::FETCH_ASSOC)) {
                   $res[] = $rows;
               }
               return $res;
           }*/
         $pp = new OKPager($sql, $limit = 15);
         $pp->conn = $conn;
         $params = array(":id" => $id);
         $msg = array();
         $msg['num_rows'] = $pp->countTotalRows($params);
         foreach ($pp->fetchData($page, $params) as $packet) {
             $msg['result'][] = $packet;
         }
         return $msg;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }