CI_DB_result::num_rows PHP Method

num_rows() public method

Number of rows in the result set
public num_rows ( ) : integer
return integer
    public function num_rows()
    {
        if (is_int($this->num_rows)) {
            return $this->num_rows;
        } elseif (count($this->result_array) > 0) {
            return $this->num_rows = count($this->result_array);
        } elseif (count($this->result_object) > 0) {
            return $this->num_rows = count($this->result_object);
        }
        return $this->num_rows = count($this->result_array());
    }

Usage Example

Example #1
0
 /**
  * Number of rows in the result set
  *
  * @return	int
  */
 public function num_rows()
 {
     // sqlsrv_num_rows() doesn't work with the FORWARD and DYNAMIC cursors (FALSE is the same as FORWARD)
     if (!in_array($this->scrollable, [FALSE, SQLSRV_CURSOR_FORWARD, SQLSRV_CURSOR_DYNAMIC], TRUE)) {
         return parent::num_rows();
     }
     return is_int($this->num_rows) ? $this->num_rows : ($this->num_rows = sqlsrv_num_rows($this->result_id));
 }
All Usage Examples Of CI_DB_result::num_rows