예제 #1
0
파일: AbsModel.php 프로젝트: makinuk/Qcore
 public function getSqlResource(array $select, EnmMysqlCondition $filter = null, EnmSqlLimit $limit = null, PrmPagination $pagination = null, $orderBy = null)
 {
     if ($pagination !== null) {
         $sql = "select SQL_CALC_FOUND_ROWS ";
         $pagination->setLimit($limit);
     } else {
         $sql = "select ";
     }
     foreach ($select as $key => $value) {
         $sql .= $value . ", ";
     }
     $sql = substr($sql, 0, -2);
     $sql .= " from " . $this->getTable();
     if ($filter != null) {
         $sql .= " where " . $filter->getSql();
     }
     if ($orderBy != null) {
         $sql .= " order by " . $orderBy;
     } else {
         $sql .= " order by Id Desc";
     }
     if ($limit != null) {
         $sql .= " limit " . $limit->start . "," . $limit->end;
     }
     return $this->executeQuery($sql);
 }