| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace KarmaFW\Database\Sql\Drivers\Mysqli;
- use \KarmaFW\Database\Sql\SqlResultset;
- use \KarmaFW\Database\Sql\SqlResultsetInterface;
- class MysqliResultset extends SqlResultset implements SqlResultsetInterface
- {
- protected $found_rows = null;
- function __construct($rs, $found_rows=null)
- {
- $this->rs = $rs;
- $this->found_rows = $found_rows;
- }
- public function fetchColumn($column_name)
- {
- $row = $this->fetchOne();
- return isset($row[$column_name]) ? $row[$column_name] : null;
- }
- public function fetchOne()
- {
- if (is_bool($this->rs)) {
- //debug_print_backtrace();
- }
- if (empty($this->rs) || $this->rs === true) {
- return [];
- }
- return mysqli_fetch_assoc($this->rs);
- }
- public function fetchAll()
- {
- $rows = parent::fetchAll();
- if (! is_null($this->found_rows)) {
- /*
- $rows = array(
- 'found_rows' => $this->found_rows,
- 'data' => $rows,
- );
- */
- }
- return $rows;
- }
- public function getRowsCount()
- {
- if (empty($this->rs)) {
- return null;
- }
- if (is_bool($this->rs)) {
- return null;
- }
- return $this->rs->num_rows;
- }
- public function getfoundRowsCount()
- {
- return $this->found_rows;
- }
- }
|