src/Laito/Database.php
public function get()
    {
        // Define columns
        $columns = count($this->columns)? $this->getColumnsString() : $this->table . '.*';

        // Define root
        $root = 'SELECT ' . $columns . ' FROM ' . $this->table;

        // Define joins
        $joins = count($this->joins)? $this->getJoinString() : '';

        // Define where conditions
        $where = $this->getWhereString();

        // Define where in conditions
        $whereIn = $this->getWhereInString();

        // Define group by
        $groupBy = ($this->groupBy)? 'GROUP BY ' . $this->groupBy : '';

        // Define order
        $orderBy = ($this->orderBy)? $this->getOrderByString() : '';

        // Define limit
        $limit = 'LIMIT ' . $this->offset . ',' . $this->limit;

        // Build query
        $this->query = implode(' ', [$root, $joins, $where, $whereIn, $groupBy, $orderBy, $limit]);

        // Debug
        if ($this->app->config('queries.log')) {
            file_put_contents($this->app->config('queries.log'), date('Y-m-d h:i:s') . ' - ' . $this->query . "\r\n", FILE_APPEND);
        }

        // Prepare statement
        $this->statement = $this->pdo->prepare($this->query);

        // Bind where values
        if (count($this->wheres)) {
            $this->bindWheres();
        }

        // Execute statement
        if (!$this->statement->execute()) {
            throw new \PDOException('Error reading from database', 500);
        }

        // Return results
        $result = $this->statement->fetchAll(\PDO::FETCH_ASSOC);

        // Reset
        $this->reset();

        // Return result
        return $result;
    }
public function get()
    {
        // Define columns
        $columns = count($this->columns)? $this->getColumnsString() : $this->table . '.*';

        // Define root
        $root = 'SELECT ' . $columns . ' FROM ' . $this->table;

        // Define joins
        $joins = count($this->joins)? $this->getJoinString() : '';

        // Define where conditions
        $where = $this->getWhereString();

        // Define where in conditions
        $whereIn = $this->getWhereInString();

        // Define group by
        $groupBy = ($this->groupBy)? 'GROUP BY ' . $this->groupBy : '';

        // Define order
        $orderBy = ($this->orderBy)? $this->getOrderByString() : '';

        // Define limit
        $limit = 'LIMIT ' . $this->offset . ',' . $this->limit;

        // Build query
        $this->query = implode(' ', [$root, $joins, $where, $whereIn, $groupBy, $orderBy, $limit]);

        // Debug
        if ($this->app->config('queries.log')) {
            file_put_contents($this->app->config('queries.log'), date('Y-m-d h:i:s') . ' - ' . $this->query . "\r\n", FILE_APPEND);
        }

        // Prepare statement
        $this->statement = $this->pdo->prepare($this->query);

        // Bind where values
        if (count($this->wheres)) {
            $this->bindWheres();
        }

        // Execute statement
        if (!$this->statement->execute()) {
            throw new \PDOException('Error reading from database', 500);
        }

        // Return results
        $result = $this->statement->fetchAll(\PDO::FETCH_ASSOC);

        // Reset
        $this->reset();

        // Return result
        return $result;
    }
public function get ( ) { // Define columns $ columns = count ( $ this -> columns ) ? $ this -> getColumnsString ( ) : $ this -> table . '.*' ; // Define root $ root = 'SELECT ' . $ columns . ' FROM ' . $ this -> table ; // Define joins $ joins = count ( $ this -> joins ) ? $ this -> getJoinString ( ) : '' ; // Define where conditions $ where = $ this -> getWhereString ( ) ; // Define where in conditions $ whereIn = $ this -> getWhereInString ( ) ; // Define group by $ groupBy = ( $ this -> groupBy ) ? 'GROUP BY ' . $ this -> groupBy : '' ; // Define order $ orderBy = ( $ this -> orderBy ) ? $ this -> getOrderByString ( ) : '' ; // Define limit $ limit = 'LIMIT ' . $ this -> offset . ',' . $ this -> limit ; // Build query $ this -> query = implode ( ' ' , [ $ root , $ joins , $ where , $ whereIn , $ groupBy , $ orderBy , $ limit ] ) ; // Debug if ( $ this -> app -> config ( 'queries.log' ) ) { file_put_contents ( $ this -> app -> config ( 'queries.log' ) , date ( 'Y-m-d h:i:s' ) . ' - ' . $ this -> query . "\r\n" , FILE_APPEND ) ; } // Prepare statement $ this -> statement = $ this -> pdo -> prepare ( $ this -> query ) ; // Bind where values if ( count ( $ this -> wheres ) ) { $ this -> bindWheres ( ) ; } // Execute statement if ( ! $ this -> statement -> execute ( ) ) { throw new \ PDOException ( 'Error reading from database' , 500 ) ; } // Return results $ result = $ this -> statement -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; // Reset $ this -> reset ( ) ; // Return result return $ result ; }
Performs a SELECT query

@return bool|array Array of results, or false
Performs a SELECT query