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; }
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; }
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; }
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; }
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; }
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; }