예제 #1
0
 /**
  * Returns an array containing all of the result set rows
  *
  * @param integer|null $type
  * @return mixed
  */
 public function fetchAll($type = null, $class = null, array $classConstructor = array())
 {
     $this->verifyMySQLiErrorsAndThrowException();
     $results = array();
     switch ($type) {
         case null:
             if (is_null($this->standartFetchMode) || count($this->standartFetchMode) == 0 || !isset($this->standartFetchMode['type'])) {
                 while ($r = $this->result->fetch_array()) {
                     $results[] = $r;
                 }
             } else {
                 $results = isset($this->standartFetchMode['param2']) ? $this->fetchAll($this->standartFetchMode['type'], $this->standartFetchMode['param2'], $this->standartFetchMode['param3']) : $this->fetchAll($this->standartFetchMode['type']);
             }
             break;
         case Fetch::FETCH_BOTH:
             while ($r = $this->result->fetch_array()) {
                 $results[] = $r;
             }
             break;
         case Fetch::FETCH_OBJ:
             while ($r = $this->result->fetch_object()) {
                 $results[] = $r;
             }
             break;
         case Fetch::FETCH_ASSOC:
         case Fetch::FETCH_NAMED:
             while ($r = $this->result->fetch_assoc()) {
                 $results[] = $r;
             }
             break;
         case Fetch::FETCH_NUM:
             while ($r = $this->result->fetch_assoc()) {
                 $results[] = array_values($r);
             }
             break;
         case Fetch::FETCH_CLASS:
             while ($r = $this->result->fetch_assoc()) {
                 $results[] = $this->createObjectOfClassFromFetch($r, $class, $classConstructor);
             }
             break;
         default:
             StatementException::unknownFetchType($type);
     }
     return $results;
 }