php - Yii unserialize and diff -
i have problem, trivial can not deal because snap out of still gets there error type: unserialize (): error @ offset 0 of 31 bytes
controller:
public function actionhistory($id) { $post=mymodel::model()->findall('id='.$id); if($post == null){ $error = yii::app()->errorhandler->error; if ($error) $this->render('error', array('error'=>$error)); else throw new chttpexception(404, 'page not found.'); } $dataprovider=new cactivedataprovider('mymodel',array( 'criteria'=>array( 'condition'=>'id='.$id, 'order'=>'id desc', ) )); $this->render('history',array( 'dataprovider'=>$dataprovider, 'id'=>$id, )); }
and view file:
<div class="view" style="float: left; width:100%;"> <b><?php echo chtml::encode($data->getattributelabel('id')); ?>:</b> <?php echo chtml::link(chtml::encode($data->id), array('view', 'id'=>$data->id)); ?> <br /> <div id="old" style="width: 48%; margin: 1%; float: left; "> <b><?php echo chtml::encode($data->getattributelabel('old')); ?>:</b> <div id="old" style="float: left; width:100%; background-color:rgba(248, 200, 178, 0.3)"> <?php echo chtml::encode($data->old); ?> </div> <br /> </div> <div id="diff" style="width: 48%; margin: 1%; float: left; "> <b><?php echo chtml::encode($data->getattributelabel('diff')); ?>:</b> <div id="diff" style="float: left; width:100%; background-color: rgba(210, 249, 244, 0.45);"> <?php echo chtml::encode($data->diff); ?> </div> <br /> </div> </div>
now, $data->diff
, $data->old
added database serialize, , needs use unserialize display data when tries error unserialize (): error @ offset 0 of 31 bytes or similar.
can me somehow? :)
first of change code here
$post=mymodel::model()->findall(array("condition"=>"id = $id"));
or can choose
$post=mymodel::model()->findbypk($id);
do if id primary key in database table otherwise go first one.
then correct value.
Comments
Post a Comment