Esempio n. 1
0
File: Comment.php Progetto: 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;
 }
Esempio n. 2
0
File: Bookmark.php Progetto: 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;
 }
Esempio n. 3
0
File: User.php Progetto: rjha/sc
 static function getTotal($filters)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = " select count(id) as count from sc_denorm_user ";
     $q = new MySQL\Query($mysqli);
     $q->filter($filters);
     $condition = $q->get();
     $sql .= $condition;
     $row = MySQL\Helper::fetchRow($mysqli, $sql);
     return $row;
 }
Esempio n. 4
0
File: Lists.php Progetto: rjha/sc
 static function getPagedItems($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 login.name as user_name, post.*, li.item_id, li.id as sort_id " . " from sc_list_item li " . " left join sc_post post on li.item_id = post.id " . " left join sc_login login on login.id = post.login_id ";
     $q = new MySQL\Query($mysqli);
     $q->setAlias("com\\indigloo\\sc\\model\\ListItem", "li");
     $q->filter($filters);
     $condition = $q->get();
     $sql .= $condition;
     $sql .= $q->getPagination($start, $direction, "li.id", $limit);
     $rows = MySQL\Helper::fetchRows($mysqli, $sql);
     //reverse rows for 'before' direction
     if ($direction == 'before') {
         $results = array_reverse($rows);
         return $results;
     }
     return $rows;
 }
Esempio n. 5
0
File: Group.php Progetto: rjha/sc
 static function getPagedUserGroups($start, $direction, $limit, $filters)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = "select ug.* from sc_user_group ug";
     //sanitize input
     settype($start, "integer");
     settype($limit, "integer");
     $direction = $mysqli->real_escape_string($direction);
     $q = new MySQL\Query($mysqli);
     $q->setAlias("com\\indigloo\\sc\\model\\Group", "ug");
     $q->filter($filters);
     $sql .= $q->get();
     $sql .= $q->getPagination($start, $direction, "ug.id", $limit);
     $rows = MySQL\Helper::fetchRows($mysqli, $sql);
     //reverse rows for 'before' direction
     if ($direction == 'before') {
         $results = array_reverse($rows);
         return $results;
     }
     return $rows;
 }
Esempio n. 6
0
File: Post.php Progetto: 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);
     // primary key id is an excellent proxy for created_on column
     // latest posts has max(id) and appears on top
     // so AFTER (NEXT) means id < latest post id
     $sql = " select q.*,l.name as user_name from sc_post q,sc_login l ";
     $q = new MySQL\Query($mysqli);
     $q->setAlias("com\\indigloo\\sc\\model\\Post", "q");
     //raw condition
     $q->addCondition("l.id = q.login_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;
 }