- edited description
Call exectute after fetch and fetch_first gives out an notice
Issue #22
resolved
When I execute an sql query after fetch_first or fetch I get this php notice in error.log of apache:
PHP Notice: Undefined property: Database::$_query in /var/www/includes/class.database.php on line 489
The line which produce this notice is in the public function fetch:
if ($this -> _executed == FALSE || !$this -> _query)
To fix this, it needs to be checked if the variable is set:
if ($this -> _executed == FALSE || !isset($this -> _query))
This is the same to line 520, which is in the public function fetch_first.
Whole fix:
/**
* Fetches the result of an execution.
*
* @return array Returns an Associate Array of results.
*/
public function fetch()
{
if ($this -> _executed == FALSE || !isset($this -> _query))
$this -> execute();
if (is_object($this -> _result))
{
$this -> _executed = FALSE;
// Checks whether fetch_all method is available. It is available only with MySQL
// Native Driver.
if (method_exists('mysqli_result', 'fetch_all'))
{
$results = $this -> _result -> fetch_all(MYSQLI_ASSOC);
}
else
{
for ($results = array(); $tmp = $this -> _result -> fetch_array(MYSQLI_ASSOC); )
$results[] = $tmp;
}
return $results;
}
else
{
$this -> oops('Unable to perform fetch()');
}
}
/**
* Fetches the first row of the result
*/
public function fetch_first()
{
if ($this -> _executed == FALSE || !isset($this -> _query))
$this -> execute();
if (is_object($this -> _result))
{
$this -> _executed = FALSE;
$results = $this -> _result -> fetch_array(MYSQLI_ASSOC);
return $results;
}
else
{
$this -> oops('Unable to perform fetch_first()');
}
}
Comments (3)
-
reporter -
reporter - changed status to resolved
Fixed
-
repo owner I accidently merged your fork. It breaks my release branch and git flow. Whenever you submit a fork, you should branch from master and submit that branch to me. I guess you submitted your master
- Log in to comment