Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
systems:yii2:migrations [2018/04/18 12:30] smayr |
systems:yii2:migrations [2018/04/19 10:07] (current) smayr [New Notation] |
||
---|---|---|---|
Line 267: | Line 267: | ||
class m160601_220000_skeleton extends Migration | class m160601_220000_skeleton extends Migration | ||
{ | { | ||
+ | private $useExtendedUserProfile = false; | ||
+ | | ||
public function up() | public function up() | ||
{ | { | ||
Line 272: | Line 274: | ||
$this-> | $this-> | ||
$this-> | $this-> | ||
+ | |||
+ | if ($this-> | ||
+ | $this-> | ||
+ | } | ||
} | } | ||
Line 277: | Line 283: | ||
{ | { | ||
$this-> | $this-> | ||
+ | | ||
return true; | return true; | ||
} | } | ||
Line 288: | Line 295: | ||
// Available Tables: must be listed in reverse creation order, | // Available Tables: must be listed in reverse creation order, | ||
// and dropping tables with foreign keys first. | // and dropping tables with foreign keys first. | ||
- | $targetTables= [" | + | |
+ | $targetTables= [ | ||
+ | $this-> | ||
+ | $this-> | ||
+ | | ||
| | ||
echo " | echo " | ||
Line 296: | Line 307: | ||
echo " | echo " | ||
if (in_array($curTable, | if (in_array($curTable, | ||
- | if ($curTable == 'entry' | + | if ($curTable == $this-> |
- | // | + | // |
+ | } | ||
+ | if ($curTable == $this-> | ||
+ | // | ||
} | } | ||
$this-> | $this-> | ||
$this-> | $this-> | ||
+ | } | ||
+ | | ||
+ | if ($this-> | ||
+ | // Restore any original table changes | ||
+ | $this-> | ||
} | } | ||
} | } | ||
+ | } | ||
+ | | ||
+ | private function alter_user_table() | ||
+ | { | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | // $this-> | ||
+ | // $this-> | ||
+ | // $this-> | ||
+ | // $this-> | ||
+ | $this-> | ||
+ | } | ||
+ | | ||
+ | private function restore_user_table() | ||
+ | { | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
} | } | ||
| | ||
Line 330: | Line 377: | ||
// AUTO_INCREMENT=1; | // AUTO_INCREMENT=1; | ||
| | ||
- | $this-> | + | $this-> |
' | ' | ||
' | ' | ||
Line 344: | Line 391: | ||
| | ||
// insert data as a row | // insert data as a row | ||
- | $this-> | + | $this-> |
" | " | ||
" | " | ||
Line 377: | Line 424: | ||
// AUTO_INCREMENT=1; | // AUTO_INCREMENT=1; | ||
| | ||
- | $this-> | + | $this-> |
' | ' | ||
' | ' | ||
Line 386: | Line 433: | ||
| | ||
// insert data as a row | // insert data as a row | ||
- | // | + | // |
// " | // " | ||
// " | // " | ||
Line 395: | Line 442: | ||
// table name, column names, column values | // table name, column names, column values | ||
$db = Yii:: | $db = Yii:: | ||
- | $db-> | + | $db-> |
[' | [' | ||
[ | [ | ||
Line 432: | Line 479: | ||
Method 1: | Method 1: | ||
<code php> | <code php> | ||
- | $this-> | + | $this-> |
' | ' | ||
' | ' | ||
Line 446: | Line 493: | ||
Method 2: | Method 2: | ||
<code php> | <code php> | ||
- | $this-> | + | $this-> |
' | ' | ||
' | ' | ||
Line 529: | Line 576: | ||
// USAGE: batchInsert(table_name, | // USAGE: batchInsert(table_name, | ||
$db = Yii:: | $db = Yii:: | ||
- | $db-> | + | $db-> |
[' | [' | ||
[ | [ | ||
Line 543: | Line 590: | ||
// Add reference_code to all records | // Add reference_code to all records | ||
foreach((new Query)-> | foreach((new Query)-> | ||
- | $this-> | + | $this-> |
} | } | ||
</ | </ | ||
Line 552: | Line 599: | ||
foreach((new Query)-> | foreach((new Query)-> | ||
// DELETE price WHERE reference_code = ' | // DELETE price WHERE reference_code = ' | ||
- | $this-> | + | $this-> |
} | } | ||
</ | </ | ||
Line 558: | Line 605: | ||
=== Create SQL View === | === Create SQL View === | ||
+ | Instead of viewing all entry records, you can create a view with a subset of them. For example, if we want all the entry records for brand ' | ||
<code php> | <code php> | ||
private function create_view_acme_entry() | private function create_view_acme_entry() |