Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting model name from model instance YII

Tags:

php

yii

How can i get model name from model instance. For e.x.

$model=new State;

here, State is model $model is State model instance.

I want to get model name i.e State from $model i.e model instance.

like image 258
Mohd Viqar Avatar asked May 13 '10 07:05

Mohd Viqar


1 Answers

add this method to your State Class

public function getModelName()
{
    return __CLASS__;
}

and call it like this:

$model = new State();
echo $model->getModelName();
like image 111
Matt Avatar answered Oct 10 '22 03:10

Matt