3
This commit is contained in:
+12
-12
@@ -24,9 +24,9 @@ abstract class HasBase
|
|||||||
protected $data;
|
protected $data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var IOrm
|
||||||
*/
|
*/
|
||||||
protected string $model;
|
protected IOrm $model;
|
||||||
|
|
||||||
/** @var */
|
/** @var */
|
||||||
protected $primaryId;
|
protected $primaryId;
|
||||||
@@ -38,20 +38,20 @@ abstract class HasBase
|
|||||||
/** @var Relation $_relation */
|
/** @var Relation $_relation */
|
||||||
protected Relation $_relation;
|
protected Relation $_relation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HasBase constructor.
|
* HasBase constructor.
|
||||||
* @param $model
|
* @param IOrm $model
|
||||||
* @param $primaryId
|
* @param $primaryId
|
||||||
* @param $value
|
* @param $value
|
||||||
* @param Relation $relation
|
* @param Relation $relation
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($model, $primaryId, $value, Relation $relation)
|
public function __construct(IOrm $model, $primaryId, $value, Relation $relation)
|
||||||
{
|
{
|
||||||
if (!class_exists($model)) {
|
if (!class_exists($model)) {
|
||||||
throw new Exception('Model must implement ' . ActiveRecord::class);
|
throw new Exception('Model must implement ' . ActiveRecord::class);
|
||||||
}
|
}
|
||||||
if (!in_array(ActiveRecord::class, class_implements($model))) {
|
if (!in_array(IOrm::class, class_implements($model))) {
|
||||||
throw new Exception('Model must implement ' . ActiveRecord::class);
|
throw new Exception('Model must implement ' . ActiveRecord::class);
|
||||||
}
|
}
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
|
|||||||
@@ -23,6 +23,20 @@ interface IOrm
|
|||||||
*/
|
*/
|
||||||
public static function findOne($param, $db = NULL);
|
public static function findOne($param, $db = NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function className();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ActiveQuery
|
||||||
|
* return a sql queryBuilder
|
||||||
|
*/
|
||||||
|
public static function find();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $dbName
|
* @param $dbName
|
||||||
* @return Connection
|
* @return Connection
|
||||||
|
|||||||
Reference in New Issue
Block a user