현재 Codeigniter 프레임 워크를 사용하고 있습니다. 아래 코드에서 Animal_model
개체를 갖고 싶습니다. stdClass
개체가 아닙니다.
<?php
class Animal_model extends CI_Model{
var $idanimal;
var $name;
public static $table = 'animals';
function __construct() {
parent::__construct();
}
function getone(self $animal){
$query = $this->db->get_where(self::$table, array('id_animal' => $animal->idanimal));
if($query == FALSE){
return FALSE;
}else{
return $query->row(); // How to get an Animal_model object here?
}
}
}
$lion = new Animal_model();
$lion->idanimal = 25;
var_dump($lion); // It says "object(Animal_model)".
$lion = $lion->getone($lion);
var_dump($lion); // Now it says "object(stdClass)".
?>
$query->row()
을 Animal_model 개체로 변환하는 방법은 무엇입니까?
고마워, 정확히 내가 찾고 있던거야! – Dacobah