Return a new basic result which selects all rows in this result by primary key

@return Result
972049
function primaryResult() {

        $result = $this->db->table( $this->table );
        $primary = $this->db->getPrimary( $this->table );

        if ( is_array( $primary ) ) {

            $this->execute();
            $or = array();

            foreach ( $this->rows as $row ) {

                $and = array();

                foreach ( $primary as $column ) {

                    $and[] = $this->db->is( $column, $row->__get( $column ) );

                }

                $or[] = "( " . implode( " AND ", $and ) . " )";

            }

            return $result->where( implode( " OR ", $or ) );

        }

        return $result->where( $primary, $this->getLocalKeys( $primary ) );

    }
1166672
public function loadResult()
    {
        // Get the first row from the result set as an array.
        $row = $this->fetchArray();

        if ($row) {
            $row = $row[0];
        }

        // Free up system resources and return.
        $this->freeResult();

        return $row;
    }
1084084
protected function selFromDbAll()
    {
        $selectedRows = $this->doQuery($this->selFromDbAllQuery())->fetchAll();

        $this->query = null;

        // TODO [alek13]: bring it out
        if ($this->pagedQuery) {
            $row                = static::db()->getConnection()->query('SELECT FOUND_ROWS()')->fetch();
            $this->recordsCount = reset($row);
            $this->pagesCount   = ceil($this->recordsCount / $this->recordsPerPage);
        }

        return $selectedRows;
    }
592049
function copy() {
		$new_object = new static();
		$values = $this->toArray();

		foreach (static::$_primaryKeys as $pk) {
			unset($values[$pk]);
		}

		$new_object->fromArray($values);
		return $new_object;
	}
171721
public function getResults()
    {
        $skip = ($this->page-1)*$this->limit;
        
        $cursor = $this->getCursor();
        $cursor->skip($skip);

        $results = array();
        $i = 0;

        while($cursor->valid() && $cursor->current() && $i++ < $this->limit) {

            $object = new $this->modelName();
            $object->writeAttributes($cursor->current());

            $pseudoCursor = new \stdClass();
            foreach ($object as $key => $value) {
                $pseudoCursor->$key = $value;
            }

            $results[] = $pseudoCursor;
            $cursor->skip();
        }

        return $results;
    }
1298104
public function row()
    {
        if (isset($this->rows[$this->cursor])) {
            return $this->rows[$this->cursor++];
        }

        return false;
    }
1016182
public function query($sql) {
        $result = $this->executeRaw($sql);
        if (!is_resource($result))
            $result = null;
        return new MySQLResult($this, $sql, $result, $this->lastInsertId(), $this->lastAffectedRows());
    }
1047428
public function selectAll($primary_key_value)
	{
		return $this->_select($this->_table_name, array_keys($this->_table_schema), $primary_key_value);
	}
1139885
public static function all()
     {
         $self = self::instance();
         //
         // Pagination
         //
         $sql = 'select * from '.$self->DBtable;

         return Database::read($sql, 1);
     }
342642
public function results()
    {

        if ($this->classname) {
            $orderAdapter = app(\Antares\Datatables\Adapter\OrderAdapter::class);
            $orderAdapter->setClassname($this->classname);
            $orderAdapter->setEngineInstance($this);

            $groupsFilterAdapter = app(\Antares\Datatables\Adapter\GroupsFilterAdapter::class);
            $groupsFilterAdapter->setClassname($this->classname);
            $groupsFilterAdapter->setEngineInstance($this);
        }
        return $this->query->get();
    }
612058
public function all()
    {
        $this->defaultTable();
        $sql = $this->sql;
        $this->reset();

        return DB::select($sql, PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, static::class);
    }
197832
public function total()
	{
		// Note that we do not need to parse includes at this stage, as includes do not effect
		// the primary result set, and thus do not effect the count. whereRelated() could effect
		// the count, but that method is not currently in use.
		//
		// We also reset the 'select' clause to avoid pulling unnecessary records and reset
		// the 'order by' clause to avoid referenced fields in the aforementioned 'select' clauses
		// that mgiht have been removed. Neither of these should have any effect on a count.
		$first = $this->deselect()
		              ->select($this->getQualifiedFieldName($this->getPrimaryKey()), 'count', true)
		              ->unordered()
		              ->rows(false)
		              ->first();
		              //->count;

		$total = $first ? (int)$first->count : 0;

		$this->reset();

		return $total;
	}
135096
final protected function build_query(){
        $select = empty($this->_select) ? $this->default_select() : implode(', ', $this->_select);
        $calc = $this->_calc_rows ? ' SQL_CALC_FOUND_ROWS' : '';
        $distinct = $this->_distinct ? sprintf('DISTINCT(%s)', $this->escape_column_name($this->_distinct)) : '';
        $from = empty($this->_from) ? $this->table : $this->_from;
        // Build query
        $sql = <<<SQL
          SELECT{$calc} {$distinct} {$select} FROM {$from}
SQL;
        // Add join
        $join = [];
        if( !empty($this->_join) ){
            $join = $this->_join;
        }else{
            $default_join = $this->default_join();
            if( !empty($default_join) ){
                $join = $default_join;
            }
        }
        foreach($join as list($table, $on, $method)){
            $method = 'INNER' === strtoupper($method) ? 'INNER' : 'LEFT';
            $sql .= <<<SQL
            {$method} JOIN {$table}
            ON {$on}
SQL;
        }
        // Add where
        if( !empty($this->_wheres) ){
            $where_clause = $this->build_where($this->_wheres);
            $sql .= <<<SQL
            WHERE {$where_clause}
SQL;
        }
        // Add group by
        if( !empty($this->_group_by) ){
            $group_by = implode(', ', $this->_group_by);
            $sql .= <<<SQL
            GROUP BY {$group_by}
SQL;
        }
        // Add order by
        if( !empty($this->_order_by) ){
            $order_by = implode(', ', $this->_order_by);
            $sql .= <<<SQL
            ORDER BY {$order_by}
SQL;
        }
        // Add limit
        if( !empty($this->_limit) ){
            list($per_page, $offset) = $this->_limit;
            $limit = <<<SQL
            LIMIT %d, %d
SQL;
            $sql .= sprintf($limit, $offset, $per_page);
        }
        return $sql;
    }
704008
protected function _buildSelect()
        {
            // If the query is raw, just set the $this->_values to be
            // the raw query parameters and return the raw query
            if ($this->_is_raw_query) {
                $this->_values = $this->_raw_parameters;
                return $this->_raw_query;
            }

            // Build and return the full SELECT statement by concatenating
            // the results of calling each separate builder method.
            return $this->_joinIfNotEmpty(
                " ",
                array(
                    $this->_buildSelectStart(),
                    $this->_buildJoin(),
                    $this->_buildWhere(),
                    $this->_buildGroupBy(),
                    $this->_buildHaving(),
                    $this->_buildOrderBy(),
                    $this->_buildLimit(),
                    $this->_buildOffset(),
                )
            );
        }
394388
protected function newPivotQuery()
    {
        $query = $this->newPivotStatement();

        foreach ($this->pivotWheres as $arguments) {
            call_user_func_array([$query, 'where'], $arguments);
        }

        foreach ($this->pivotWhereIns as $arguments) {
            call_user_func_array([$query, 'whereIn'], $arguments);
        }

        return $query->where($this->foreignKey, $this->parent->getKey());
    }
544592
public function getResult()
    {
        if ($this->map->currentModel->row instanceof Sql\DataObjects\Result\Row) {
            $criteria = $this->map->currentModel->row->offsetGet($this->map->currentPrimaryKey);
            $condition = [
                $this->map->intermediaryTable . '.' . $this->map->intermediaryCurrentForeignKey => $criteria,
            ];

            $this->map->intermediaryModel->qb
                ->select([
                    $this->map->referenceTable . '.*',
                ])
                ->from($this->map->intermediaryTable)
                ->join($this->map->referenceTable, implode(' = ', [
                    $this->map->referenceTable . '.' . $this->map->referencePrimaryKey,
                    $this->map->intermediaryTable . '.' . $this->map->intermediaryReferenceForeignKey,
                ]));

            if ($result = $this->map->intermediaryModel->findWhere($condition)) {
                return $result;
            }
        }

        return false;
    }
73996
protected function baseQuery()
    {
        if (empty($this->baseQuery) && $this->parent->getData()) {
            $pk    = $this->parent->getPk();
            $table = $this->pivot->getTable();

            $this->query
                ->join($table . ' pivot', 'pivot.' . $this->foreignKey . '=' . $this->query->getTable() . '.' . $this->query->getPk())
                ->where('pivot.' . $this->localKey, $this->parent->$pk);
            $this->baseQuery = true;
        }
    }