public function getFirst($sql = null)
    {
        if ($sql) {
            $this->setLastQuery($sql);

            try {
                $result = $this->db->query($sql);
            } catch (\PDOException $e) {
                throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
            }

            $data = $this->fetchAssoc($result);

            if (isset($data[0])) {
                return $data[0];
            }

            return null;
        }

        return $this->limit(1)->query()->fetchAssoc();
    }
public function getFirst($sql = null)
    {
        if ($sql) {
            $this->setLastQuery($sql);

            try {
                $result = $this->db->query($sql);
            } catch (\PDOException $e) {
                throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
            }

            $data = $this->fetchAssoc($result);

            if (isset($data[0])) {
                return $data[0];
            }

            return null;
        }

        return $this->limit(1)->query()->fetchAssoc();
    }
public function getFirst ( $ sql = null ) { if ( $ sql ) { $ this -> setLastQuery ( $ sql ) ; try { $ result = $ this -> db -> query ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new DatabaseException ( $ e -> getMessage ( ) . '<br>' . $ this -> getLastQuery ( ) [ 0 ] ) ; } $ data = $ this -> fetchAssoc ( $ result ) ; if ( isset ( $ data [ 0 ] ) ) { return $ data [ 0 ] ; } return null ; } return $ this -> limit ( 1 ) -> query ( ) -> fetchAssoc ( ) ; }
Return the first the matching row

@param null $sql Optional query string

@return array|null
@throws DatabaseException
Return the first the matching row