Example #1
0
File: Comment.php Project: rjha/sc
 static function getPaged($start, $direction, $limit, $filters)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //sanitize input
     settype($start, "integer");
     settype($limit, "integer");
     $direction = $mysqli->real_escape_string($direction);
     $sql = " select a.*,l.name as user_name from sc_comment a,sc_login l ";
     $q = new MySQL\Query($mysqli);
     $q->setAlias("com\\indigloo\\sc\\model\\Comment", "a");
     //raw condition
     $q->addCondition("l.id = a.login_id");
     $q->filter($filters);
     $sql .= $q->get();
     $sql .= $q->getPagination($start, $direction, "a.id", $limit);
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug("sql => {$sql} \n");
     }
     $rows = MySQL\Helper::fetchRows($mysqli, $sql);
     //reverse rows for 'before' direction
     if ($direction == 'before') {
         $results = array_reverse($rows);
         return $results;
     }
     return $rows;
 }
Example #2
0
File: Bookmark.php Project: rjha/sc
 static function getPaged($start, $direction, $limit, $filters)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //sanitize input
     settype($start, "integer");
     settype($limit, "integer");
     $direction = $mysqli->real_escape_string($direction);
     $sql = " select q.* , l.name as user_name from sc_post q, sc_bookmark a, sc_login l ";
     $q = new MySQL\Query($mysqli);
     $q->setAlias("com\\indigloo\\sc\\model\\Bookmark", "a");
     $q->addCondition("q.pseudo_id = a.object_id ");
     $q->addCondition("q.login_id = l.id");
     $q->filter($filters);
     $sql .= $q->get();
     $sql .= $q->getPagination($start, $direction, "q.id", $limit);
     $rows = MySQL\Helper::fetchRows($mysqli, $sql);
     //reverse rows for 'before' direction
     if ($direction == 'before') {
         $results = array_reverse($rows);
         return $results;
     }
     return $rows;
 }
Example #3
0
File: Post.php Project: rjha/sc
 static function getPagedOnCategory($start, $direction, $limit, $code)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //sanitize input
     $code = $mysqli->real_escape_string($code);
     $direction = $mysqli->real_escape_string($direction);
     settype($start, "integer");
     settype($limit, "integer");
     $sql = " select q.*,l.name as user_name from sc_post q,sc_login l ";
     $codeCondition = sprintf("cat_code = '%s'", $code);
     $q = new MySQL\Query($mysqli);
     $q->addCondition("l.id = q.login_id");
     $q->addCondition($codeCondition);
     $sql .= $q->get();
     $sql .= $q->getPagination($start, $direction, "q.id", $limit);
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug("sql => {$sql} \n");
     }
     $rows = MySQL\Helper::fetchRows($mysqli, $sql);
     //reverse rows for 'before' direction
     if ($direction == 'before') {
         $results = array_reverse($rows);
         return $results;
     }
     return $rows;
 }