DBStatement.php (mrbs-1.9.4) | : | DBStatement.php (mrbs-1.10.0) | ||
---|---|---|---|---|
<?php | <?php | |||
namespace MRBS; | namespace MRBS; | |||
use PDO; | use PDO; | |||
use PDOStatement; | ||||
// | // | |||
class DBStatement | class DBStatement | |||
{ | { | |||
protected $db_object = null; | protected $db_object = null; | |||
protected $statement = null; | protected $statement = null; | |||
// | // | |||
public function __construct(DB $db_obj, \PDOStatement $sth) | public function __construct(DB $db_obj, PDOStatement $sth) | |||
{ | { | |||
$this->db_object = $db_obj; | $this->db_object = $db_obj; | |||
$this->statement = $sth; | $this->statement = $sth; | |||
} | } | |||
// Returns the next row from a statement. | // Returns the next row from a statement. | |||
// The row is returned as an array with index 0=first column, etc. | // The row is returned as an array with index 0=first column, etc. | |||
// Returns FALSE if there are no more rows. | // Returns FALSE if there are no more rows. | |||
public function next_row() | public function next_row() | |||
{ | { | |||
skipping to change at line 37 | skipping to change at line 38 | |||
// Return a row from a statement as an associative array keyed by field name. | // Return a row from a statement as an associative array keyed by field name. | |||
// Returns FALSE if there are no more rows. | // Returns FALSE if there are no more rows. | |||
public function next_row_keyed() | public function next_row_keyed() | |||
{ | { | |||
return $this->statement->fetch(PDO::FETCH_ASSOC); | return $this->statement->fetch(PDO::FETCH_ASSOC); | |||
} | } | |||
// Return all the rows from a statement object, as an array of arrays | // Return all the rows from a statement object, as an array of arrays | |||
// keyed on the column name | // keyed on the column name | |||
public function all_rows_keyed() | public function all_rows_keyed() : array | |||
{ | { | |||
$result = array(); | $result = array(); | |||
while (false !== ($row = $this->next_row_keyed())) | while (false !== ($row = $this->next_row_keyed())) | |||
{ | { | |||
$result[] = $row; | $result[] = $row; | |||
} | } | |||
return $result; | return $result; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 3 lines changed or added |