MySQL::RecordsArray PHP Method

RecordsArray() public method

Returns all records from last query and returns contents as array or FALSE on error
public RecordsArray ( integer $resultType = MYSQLI_BOTH ) : Records
$resultType integer (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH
return Records in array form
    public function RecordsArray($resultType = MYSQLI_BOTH)
    {
        $this->ResetError();
        if ($this->last_result) {
            if (!mysqli_data_seek($this->last_result, 0)) {
                $this->SetError();
                return false;
            } else {
                //while($member = mysqli_fetch_object($this->last_result)){
                while ($member = mysqli_fetch_array($this->last_result, $resultType)) {
                    $members[] = $member;
                }
                mysqli_data_seek($this->last_result, 0);
                $this->active_row = 0;
                return $members;
            }
        } else {
            $this->active_row = -1;
            $this->SetError("No query results exist", -1);
            return false;
        }
    }

Usage Example

Example #1
0
 /**
  * @return array|bool
  */
 public function membership_roles()
 {
     $p = $this->kga['server_prefix'];
     $query = "SELECT a.*, COUNT(DISTINCT b.userID) as count_users FROM `{$p}membershipRoles` a LEFT JOIN `{$p}groups_users` b USING(membershipRoleID) GROUP BY a.membershipRoleID";
     $result = $this->conn->Query($query);
     if ($result == false) {
         $this->logLastError('membership_roles');
         return false;
     }
     $rows = $this->conn->RecordsArray(MYSQLI_ASSOC);
     return $rows;
 }
All Usage Examples Of MySQL::RecordsArray