Различия
Показаны различия между двумя версиями страницы.
| Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
| yii2:docs [2017/01/04 22:43] – [Cache] mirocow | yii2:docs [2019/04/18 13:17] (текущий) – [Active Record] mirocow | ||
|---|---|---|---|
| Строка 290: | Строка 290: | ||
| }); | }); | ||
| </ | </ | ||
| + | |||
| + | ==== Form ==== | ||
| + | |||
| + | * [[yii2: | ||
| + | * [[yii2: | ||
| + | |||
| + | **Подробно** https:// | ||
| ===== Ajax ===== | ===== Ajax ===== | ||
| Строка 368: | Строка 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-> |
| - | -> | + | -> |
| ': | ': | ||
| - | | + | |
| -> | -> | ||
| } | } | ||
| Строка 409: | Строка 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:: | ||
| - | | + | |
| | | ||
| Строка 425: | Строка 432: | ||
| // the result as an array | // the result as an array | ||
| $posts = $query-> | $posts = $query-> | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | User:: | ||
| + | User:: | ||
| </ | </ | ||
| Строка 528: | Строка 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 | ||
| + | ' | ||
| + | ' | ||
| + | // ... | ||
| + | ], | ||
| ]; | ]; | ||
| } | } | ||
| Строка 691: | Строка 717: | ||
| print_r($query-> | print_r($query-> | ||
| </ | </ | ||
| - | ==== DAO ==== | + | ==== Объекты доступа к данным (Data Access Objects, |
| === Соеденение === | === Соеденение === | ||
| Строка 713: | Строка 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> | ||
| Строка 765: | Строка 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 ==== | ||
| Строка 865: | Строка 891: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| ===== Controller ===== | ===== Controller ===== | ||
| Строка 884: | Строка 911: | ||
| **Подробно** https:// | **Подробно** https:// | ||
| + | ===== Module ===== | ||
| + | |||
| + | ==== Submodule ==== | ||
| + | |||
| + | Для работы сабмодуля, | ||
| + | <code php> | ||
| + | namespace mirocow\eav; | ||
| + | |||
| + | class Module extends \yii\base\Module { | ||
| + | | ||
| + | // ... | ||
| + | public function init() { | ||
| + | |||
| + | // .. | ||
| + | |||
| + | $this-> | ||
| + | } | ||
| + | | ||
| + | // Пример перенаправления роута в саб модуль admin | ||
| + | public function createController($route) { | ||
| + | | ||
| + | return $this-> | ||
| + | | ||
| + | } | ||
| + | | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Helpers ==== | ||
| + | |||
| + | * https:// | ||
| + | |||
| + | ==== Behaviors/ | ||
| + | |||
| + | <code php> | ||
| + | public function behaviors() | ||
| + | { | ||
| + | return array( | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | array(' | ||
| + | array(' | ||
| + | ), | ||
| + | ), | ||
| + | ); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Behaviors/ | ||
| + | |||
| + | <code php> | ||
| + | public function behaviors() { | ||
| + | return [ | ||
| + | [ | ||
| + | ' | ||
| + | ' | ||
| + | //' | ||
| + | ' | ||
| + | ], | ||
| + | ]; | ||
| + | } | ||
| + | </ | ||
| ===== Session ===== | ===== Session ===== | ||
| Строка 943: | Строка 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 ===== | ||
| Строка 1089: | Строка 1220: | ||
| apt=get install php5-intl | apt=get install php5-intl | ||
| + | |||
| + | ==== Перевод (локализация проекта) ==== | ||
| + | |||
| + | * https:// | ||
| ===== PHPUnit ===== | ===== PHPUnit ===== | ||
| Строка 1104: | Строка 1239: | ||
| * php vendor/ | * php vendor/ | ||
| - | ===== Статьи ===== | + | ====== Статьи |
| * https:// | * https:// | ||
| Строка 1110: | Строка 1245: | ||
| * http:// | * http:// | ||
| - | ===== Описание ===== | + | ====== Описание |
| * https:// | * https:// | ||