1 | <?php |
||
21 | class Seo extends Model |
||
22 | { |
||
23 | /** |
||
24 | * @var string suffix for build table name for the tables stored SEO data for ActiveRecord |
||
25 | */ |
||
26 | static public $tableSuffix = 'seo'; |
||
27 | /** |
||
28 | * @var int SEO data owner model id |
||
29 | */ |
||
30 | public $model_id; |
||
31 | /** |
||
32 | * @var int SEO data condition |
||
33 | */ |
||
34 | public $condition = 0; |
||
35 | /** |
||
36 | * @var string SEO title |
||
37 | */ |
||
38 | public $title = ''; |
||
39 | /** |
||
40 | * @var string SEO keywords |
||
41 | */ |
||
42 | public $keywords = ''; |
||
43 | /** |
||
44 | * @var string SEO description |
||
45 | */ |
||
46 | public $description = ''; |
||
47 | /** |
||
48 | * @var bool new record flag |
||
49 | */ |
||
50 | protected $_isNewRecord; |
||
51 | /** |
||
52 | * @var ActiveRecord SEO data owner |
||
53 | */ |
||
54 | protected $_owner; |
||
55 | |||
56 | /** |
||
57 | * Search SEO data. If not found, will be returned new SEO model with empty data |
||
58 | * @param ActiveRecord $owner the ActiveRecord model for which to find data |
||
59 | * @param int $condition optional condition for searched SEO data |
||
60 | * @return self |
||
61 | */ |
||
62 | 1 | public static function find(ActiveRecord $owner, $condition = 0) |
|
79 | |||
80 | /** |
||
81 | * Get table name of SEO data table for ActiveRecord |
||
82 | * @param ActiveRecord $activeRecord |
||
83 | * @return string |
||
84 | */ |
||
85 | 1 | static public function tableName(ActiveRecord $activeRecord) |
|
94 | |||
95 | /** |
||
96 | * Find all SEO data. |
||
97 | * Result will be in format ['condition1'=>Seo(), 'condition2'=>Seo(), ...] |
||
98 | * @param ActiveRecord $owner the model for which to find data |
||
99 | * @return self[] |
||
100 | */ |
||
101 | 1 | public static function findAll(ActiveRecord $owner) |
|
117 | |||
118 | /** |
||
119 | * Delete all SEO data for ActiveRecord |
||
120 | * @param ActiveRecord $owner |
||
121 | */ |
||
122 | 1 | static public function deleteAll(ActiveRecord $owner) |
|
126 | |||
127 | /** |
||
128 | * @return array |
||
129 | */ |
||
130 | 1 | public function rules() |
|
136 | |||
137 | /** |
||
138 | * Save SEO data |
||
139 | */ |
||
140 | 1 | public function save() |
|
166 | |||
167 | /** |
||
168 | * Delete SEO data |
||
169 | * @return $this|bool |
||
170 | */ |
||
171 | 1 | public function delete() |
|
182 | |||
183 | /** |
||
184 | * Get isNewRecord flag |
||
185 | * @return bool |
||
186 | */ |
||
187 | 1 | public function getIsNewRecord() |
|
191 | } |
||
192 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.