PHP Error

$obj must be id if not CActieRecord

/home/napocasaimobiliare/domains/napocaimobiliare.ro/public_html/protected/components/Shared.php(16)

04     private static $cache = array();
05     static function data($obj, $type=NULL) {
06         //if obj add it to cache
07         if(is_a($obj, 'CActiveRecord')) {
08             $class = get_class($obj);
09             $id = $obj->getPrimaryKey();
10             if(!is_array($id) && !isset(self::$cache[$class][$id])) self::$cache[$class][$id] = $obj;
11             return $obj;
12         }
13     
14         //some safety checks
15         //note: it does not support composite primary keys
16         if(!is_numeric($obj)) trigger_error('$obj must be id if not CActieRecord', E_USER_ERROR);
17         if(is_null($type)) trigger_error('$type required unless CActieRecord obj', E_USER_ERROR);        
18         
19         if(isset(self::$cache[$type][(int)$obj])) return self::$cache[$type][(int)$obj];
20     
21         $ret = CActiveRecord::model($type)->findByPk($obj);
22         if(!$ret) return $ret;
23         $id = $ret->getPrimaryKey();
24         if(!is_array($id)) self::$cache[$type][$id] = $ret;
25     
26         return $ret;
27     }
28 }

Stack Trace

#0
+
 /home/napocasaimobiliare/domains/napocaimobiliare.ro/public_html/protected/components/Shared.php(16): trigger_error("$obj must be id if not CActieRecord", 256)
11             return $obj;
12         }
13     
14         //some safety checks
15         //note: it does not support composite primary keys
16         if(!is_numeric($obj)) trigger_error('$obj must be id if not CActieRecord', E_USER_ERROR);
17         if(is_null($type)) trigger_error('$type required unless CActieRecord obj', E_USER_ERROR);        
18         
19         if(isset(self::$cache[$type][(int)$obj])) return self::$cache[$type][(int)$obj];
20     
21         $ret = CActiveRecord::model($type)->findByPk($obj);
#1
+
 /home/napocasaimobiliare/domains/napocaimobiliare.ro/public_html/protected/components/EstateRoute.php(142): Shared::data("", "Hood")
137                         //return false;
138                 }// ~ switch ($params['type'])  
139             }// ~ if($params['language'] == 'en')
140             if(!is_numeric($params['city_id']) && !is_numeric($params['hood_id'])) $url.= $district;
141             else if(isset($params['hood_id'])) {
142                 $hood = Shared::data($params['hood_id'], 'Hood');
143                 if($hood) {
144                     $city = Shared::data($hood->city_id, 'City');
145                     if($city) {
146                         if(isset($params['city_id']) && $params['city_id']!=$city->getPrimaryKey()) trigger_error("City id missmatch", E_USER_ERROR);
147                         $url.=strtolower(str_replace(' ', '-', $city->name.'+'.$hood->name));
#3
+
 /home/napocasaimobiliare/domains/napocaimobiliare.ro/public_html/protected/components/UrlManager.php(8): CUrlManager->createUrl("estate/index", array("hood_id" => null, "language" => "ro", "tranzaction" => 0, "type" => 6, ...), "&")
03 {
04     public function createUrl($route,$params=array(),$ampersand='&')
05     {
06         //var_dump($route);die();
07         if(strcasecmp('admin/', substr($route, 0, 6)) !== 0 && !isset($params['language'])) $params['language'] = Yii::app()->language;
08         return parent::createUrl($route, $params, $ampersand);    
09     }
10     public function parseUrl($request)
11     {
12         $ret = parent::parseUrl($request);
13 
2024-03-28 19:33:41 Apache Yii Framework/1.1.8