Result有一个可选
$type参数,该参数决定返回哪种类型的结果。默认情况下(
$type ="object"),它返回一个对象(
result_object())。可以将其设置为
"array",然后将返回结果数组,该结果等同于caling
result_array()。第三个版本接受自定义类以用作结果对象。
来自CodeIgniter的代码:
public function result($type = 'object'){ if ($type === 'array') { return $this->result_array(); } elseif ($type === 'object') { return $this->result_object(); } else { return $this->custom_result_object($type); }}数组从技术上讲速度更快,但它们不是对象。这取决于您要在哪里使用结果。大多数时候,数组就足够了。



