/
ActiveRecord.php
57 lines (50 loc) · 1.66 KB
/
ActiveRecord.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @link http://poodev.github.io/
* @copyright Copyright (c) 2019 MPu Technology
* @license http://poodev.github.io/license/
*/
namespace poo\db;
/**
* ActiveRecord is the base class for classes representing relational data in terms of objects.
*
* This class wrapping 'findX' function that return ActiveQuery with 'queryX' function.
* Aimed for name consistency.
* So, findX function only result data (array). Maybe will be replace with fetchX function.
*
* @author Agus Suhartono <agus.suhartono@gmail.com>
* @since 1.0.0-alpha1
*/
class ActiveRecord extends \yii\db\ActiveRecord
{
/**
* Return ActiveQueri of ActiveRecord
*
* @return yii/db/ActiveQuery the newly created [[yii/db/ActiveQuery]] instance.
*/
public static function query()
{
return static::find();
}
/**
* Creates an [[ActiveQuery]] instance with a given SQL statement.
*
* @param string $sql the SQL statement to be executed
* @param array $params parameters to be bound to the SQL statement during execution.
* @return yii/db/ActiveQuery the newly created [[yii/db/ActiveQuery]] instance.
*/
public static function queryBySql($sql, $params = [])
{
return static::findBySql($sql, $params);
}
/**
* Get ActiveQuery of ActiveRecord with condition
*
* @param mixed $condition please refer to [[findOne()]] for the explanation of this parameter
* @return yii/db/ActiveQuery the newly created [[yii/db/ActiveQuery]] instance.
*/
protected static function queryByCondition($condition)
{
return static::findByCondition($condition);
}
}