public function get($limit = 0, $offset = 0)
    {

        //check if there is an error
        if (static::$response['status'] == "error") {
           return static::terminate(static::$response);
        }

        //check if the limit is a number
        if (!is_numeric($limit)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter limit should be numeric at function get()";
            static::$response["code"] = 6000;

            return static::terminate(static::$response);
        }

        //check if the offset is a number
        if (!is_numeric($offset)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter offset should be numeric at function get()";
            static::$response["code"] = 6001;

            return static::terminate(static::$response);
        }

        $table_name = self::$table;

        /* if no column passed as param, select all	 */
        $columns = empty($this->columns) ? "*" : $this->columns;

        $query = /** @lang text */
            "SELECT {$columns} FROM {$table_name}";

        if (!empty($this->whereby)) {

            $query = $query . ' WHERE ' . $this->whereby;
        }
        if(!empty($this->groupby)){
            $query.=' GROUP BY '.$this->groupby;
        }

        if (!empty($this->order)) {
            $query .= $this->order;
        }


        if (!empty($limit)) {
            $query = $query . ' LIMIT ' . $limit;
        }
        if (!empty($offset)) {
            $query = $query . ' OFFSET ' . $offset;
        }



          return  $this->fetch($query);
    }
public function get($limit = 0, $offset = 0)
    {

        //check if there is an error
        if (static::$response['status'] == "error") {
           return static::terminate(static::$response);
        }

        //check if the limit is a number
        if (!is_numeric($limit)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter limit should be numeric at function get()";
            static::$response["code"] = 6000;

            return static::terminate(static::$response);
        }

        //check if the offset is a number
        if (!is_numeric($offset)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter offset should be numeric at function get()";
            static::$response["code"] = 6001;

            return static::terminate(static::$response);
        }

        $table_name = self::$table;

        /* if no column passed as param, select all	 */
        $columns = empty($this->columns) ? "*" : $this->columns;

        $query = /** @lang text */
            "SELECT {$columns} FROM {$table_name}";

        if (!empty($this->whereby)) {

            $query = $query . ' WHERE ' . $this->whereby;
        }
        if(!empty($this->groupby)){
            $query.=' GROUP BY '.$this->groupby;
        }

        if (!empty($this->order)) {
            $query .= $this->order;
        }


        if (!empty($limit)) {
            $query = $query . ' LIMIT ' . $limit;
        }
        if (!empty($offset)) {
            $query = $query . ' OFFSET ' . $offset;
        }



          return  $this->fetch($query);
    }
public function get ( $ limit = 0 , $ offset = 0 ) { //check if there is an error if ( static :: $ response [ 'status' ] == "error" ) { return static :: terminate ( static :: $ response ) ; } //check if the limit is a number if ( ! is_numeric ( $ limit ) ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = "Parameter limit should be numeric at function get()" ; static :: $ response [ "code" ] = 6000 ; return static :: terminate ( static :: $ response ) ; } //check if the offset is a number if ( ! is_numeric ( $ offset ) ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = "Parameter offset should be numeric at function get()" ; static :: $ response [ "code" ] = 6001 ; return static :: terminate ( static :: $ response ) ; } $ table_name = self :: $ table ; /* if no column passed as param, select all	 */ $ columns = empty ( $ this -> columns ) ? "*" : $ this -> columns ; $ query = /** @lang text */ "SELECT {$columns} FROM {$table_name}" ; if ( ! empty ( $ this -> whereby ) ) { $ query = $ query . ' WHERE ' . $ this -> whereby ; } if ( ! empty ( $ this -> groupby ) ) { $ query .= ' GROUP BY ' . $ this -> groupby ; } if ( ! empty ( $ this -> order ) ) { $ query .= $ this -> order ; } if ( ! empty ( $ limit ) ) { $ query = $ query . ' LIMIT ' . $ limit ; } if ( ! empty ( $ offset ) ) { $ query = $ query . ' OFFSET ' . $ offset ; } return $ this -> fetch ( $ query ) ; }
Fetch records form database
@param int $limit :optional limit of records to be retrieved
@param int $offset :the index which the record should be retrieved from
@return array|string
Fetch records form database