I am trying to create a father class like:
class CommonModel extends \Common\Model\CommonModel {
protected static $_instance = null; //singleton
/**
* singleton
* @return null|static
* @Date 2017/4/7 14:06
*/
public static function instance(){
if(!isset(self::$_instance)){
self::$_instance = new static();
}
return self::$_instance;
}
UserModel and UserThirdModel implements the CommonModel
when I create $user = UserModel::instance(); //an user instance is created
$userThird = UserThirdModel::instance();// userModel retured.
I see the problem comes from "if(!isset(self::$_instance)){"
my question is how to create different instance based on different model
Thanks