Различия
Показаны различия между двумя версиями страницы.
| Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
| yii2:docs [2017/01/04 22:49] – mirocow | yii2:docs [2019/04/18 13:17] (текущий) – [Active Record] mirocow | ||
|---|---|---|---|
| Строка 375: | Строка 375: | ||
| public function getCreator() | public function getCreator() | ||
| { | { | ||
| - | return $this-> | + | return $this-> |
| } | } | ||
| public function getComments() | public function getComments() | ||
| { | { | ||
| - | return $this-> | + | return $this-> |
| } | } | ||
| public function getTrustComments($isTrust = true) | public function getTrustComments($isTrust = true) | ||
| { | { | ||
| - | return $this-> | + | return $this-> |
| - | -> | + | -> |
| ': | ': | ||
| - | | + | |
| -> | -> | ||
| } | } | ||
| Строка 416: | Строка 416: | ||
| // looking for a post | // looking for a post | ||
| $post = $query | $post = $query | ||
| - | | + | |
| | | ||
| // or easier: " | // or easier: " | ||
| - | $post = Post::find(array(' | + | $post = Post::find([' |
| // having transmitted to the factory method not a massive, but a number equivalent to the primary key search | // having transmitted to the factory method not a massive, but a number equivalent to the primary key search | ||
| $post = Post:: | $post = Post:: | ||
| - | | + | |
| | | ||
| Строка 432: | Строка 432: | ||
| // the result as an array | // the result as an array | ||
| $posts = $query-> | $posts = $query-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | User:: | ||
| + | User:: | ||
| </ | </ | ||
| Строка 535: | Строка 540: | ||
| { | { | ||
| return [ | return [ | ||
| - | [' | + | |
| - | ' | + | |
| - | // specifies in which scenario(s) this rule is active. | + | ' |
| - | // if not given, it means it is active in all scenarios | + | // specifies in which scenario(s) this rule is active. |
| - | ' | + | // if not given, it means it is active in all scenarios |
| - | // the following name-value pairs will be used | + | ' |
| - | // to initialize the validator properties | + | // the following name-value pairs will be used |
| - | ' | + | // to initialize the validator properties |
| - | ' | + | ' |
| - | // ... | + | ' |
| + | // ... | ||
| + | | ||
| + | [ | ||
| + | [' | ||
| + | ' | ||
| + | | ||
| + | // if not given, it means it is active in all scenarios | ||
| + | ' | ||
| + | // the following name-value pairs will be used | ||
| + | // to initialize the validator properties | ||
| + | ' | ||
| + | ' | ||
| + | // ... | ||
| + | ], | ||
| ]; | ]; | ||
| } | } | ||
| Строка 698: | Строка 717: | ||
| print_r($query-> | print_r($query-> | ||
| </ | </ | ||
| - | ==== DAO ==== | + | ==== Объекты доступа к данным (Data Access Objects, |
| === Соеденение === | === Соеденение === | ||
| Строка 720: | Строка 739: | ||
| **Подробно** | **Подробно** | ||
| - | == Query Builder and Query == | + | == createCommand == |
| + | |||
| + | <code php> | ||
| + | $command = $connection-> | ||
| + | $post = $command-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | $connection-> | ||
| + | ' | ||
| + | ' | ||
| + | ])-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | $command = $connection-> | ||
| + | $command-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | $connection-> | ||
| + | [' | ||
| + | [' | ||
| + | [' | ||
| + | ])-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | $connection-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | $connection-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | $command = $connection-> | ||
| + | $command-> | ||
| + | $post = $command-> | ||
| + | </ | ||
| + | |||
| + | ==== Построитель запросов (Query Builder and Query) ==== | ||
| <code php> | <code php> | ||
| Строка 772: | Строка 832: | ||
| * https:// | * https:// | ||
| - | |||
| - | == createCommand == | ||
| - | |||
| - | <code php> | ||
| - | $command = $connection-> | ||
| - | $post = $command-> | ||
| - | </ | ||
| - | |||
| - | <code php> | ||
| - | $connection-> | ||
| - | ' | ||
| - | ' | ||
| - | ])-> | ||
| - | </ | ||
| - | |||
| - | <code php> | ||
| - | $command = $connection-> | ||
| - | $command-> | ||
| - | </ | ||
| - | |||
| - | <code php> | ||
| - | $connection-> | ||
| - | [' | ||
| - | [' | ||
| - | [' | ||
| - | ])-> | ||
| - | </ | ||
| - | |||
| - | <code php> | ||
| - | $connection-> | ||
| - | </ | ||
| - | |||
| - | <code php> | ||
| - | $connection-> | ||
| - | </ | ||
| - | |||
| - | <code php> | ||
| - | $command = $connection-> | ||
| - | $command-> | ||
| - | $post = $command-> | ||
| - | </ | ||
| ==== Transactions ==== | ==== Transactions ==== | ||
| Строка 929: | Строка 948: | ||
| public function behaviors() | public function behaviors() | ||
| { | { | ||
| - | | + | |
| - | ' | + | ' |
| - | ' | + | ' |
| - | ' | + | ' |
| - | array(' | + | array(' |
| - | array(' | + | array(' |
| - | ), | + | ), |
| - | ), | + | ), |
| - | ); | + | ); |
| } | } | ||
| </ | </ | ||
| + | ==== Behaviors/ | ||
| + | |||
| + | <code php> | ||
| + | public function behaviors() { | ||
| + | return [ | ||
| + | [ | ||
| + | ' | ||
| + | ' | ||
| + | //' | ||
| + | ' | ||
| + | ], | ||
| + | ]; | ||
| + | } | ||
| + | </ | ||
| ===== Session ===== | ===== Session ===== | ||
| Строка 1000: | Строка 1033: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ==== Params / Параметры ==== | ||
| + | |||
| + | <code php> | ||
| + | <?php | ||
| + | |||
| + | namespace console\controllers; | ||
| + | |||
| + | use yii\console\Controller; | ||
| + | |||
| + | class QueueController extends Controller | ||
| + | { | ||
| + | public $pid_file = ''; | ||
| + | |||
| + | public function __get($name) | ||
| + | { | ||
| + | $name = str_replace(' | ||
| + | |||
| + | return $this-> | ||
| + | } | ||
| + | |||
| + | public function __set($name, | ||
| + | { | ||
| + | $name = str_replace(' | ||
| + | |||
| + | $this-> | ||
| + | } | ||
| + | |||
| + | |||
| + | public function options($actionID) | ||
| + | { | ||
| + | return [' | ||
| + | } | ||
| + | |||
| + | public function actionRun() | ||
| + | { | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| ===== User ===== | ===== User ===== | ||
| Строка 1146: | Строка 1220: | ||
| apt=get install php5-intl | apt=get install php5-intl | ||
| + | |||
| + | ==== Перевод (локализация проекта) ==== | ||
| + | |||
| + | * https:// | ||
| ===== PHPUnit ===== | ===== PHPUnit ===== | ||