| Conditions | 3 |
| Paths | 4 |
| Total Lines | 47 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 62 | public function prepare() |
||
| 63 | { |
||
| 64 | // Perform SQL table creation |
||
| 65 | $path = __DIR__.'/../sql/'; |
||
| 66 | foreach (array_slice(scandir($path), 2) as $file) { |
||
| 67 | db()->query($this->readSQL($path.$file, $this->tablePrefix)); |
||
| 68 | } |
||
| 69 | |||
| 70 | // Initiate migration mechanism |
||
| 71 | db()->migration(get_class($this), array($this, 'migrator')); |
||
| 72 | |||
| 73 | // Define permanent table relations |
||
| 74 | new TableRelation('material', 'user', 'UserID', 0, 'user_id'); |
||
| 75 | new TableRelation('material', 'gallery', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 76 | new TableRelation('material', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 77 | new TableRelation('material', 'field', 'materialfield.FieldID', TableRelation::T_ONE_TO_MANY); |
||
| 78 | new TableRelation('material', 'structurematerial', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 79 | new TableRelation('material', 'structure', 'structurematerial.StructureID', TableRelation::T_ONE_TO_MANY); |
||
| 80 | new TableRelation('materialfield', 'field', 'FieldID'); |
||
| 81 | new TableRelation('materialfield', 'material', 'MaterialID'); |
||
| 82 | new TableRelation('structurematerial', 'structure', 'StructureID'); |
||
| 83 | new TableRelation('structurematerial', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 84 | new TableRelation('structurematerial', 'material', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 85 | new TableRelation('structure', 'material', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials'); |
||
|
1 ignored issue
–
show
|
|||
| 86 | new TableRelation('structure', 'gallery', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials'); |
||
|
1 ignored issue
–
show
|
|||
| 87 | /*new TableRelation( 'structure', 'material', 'MaterialID' );*/ |
||
| 88 | new TableRelation('structure', 'user', 'UserID', 0, 'user_id'); |
||
| 89 | new TableRelation('structure', 'materialfield', 'material.MaterialID', TableRelation::T_ONE_TO_MANY, 'MaterialID', '_mf'); |
||
|
1 ignored issue
–
show
|
|||
| 90 | new TableRelation('structure', 'structurematerial', 'StructureID', TableRelation::T_ONE_TO_MANY); |
||
| 91 | new TableRelation('related_materials', 'material', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID'); |
||
|
1 ignored issue
–
show
|
|||
| 92 | new TableRelation('related_materials', 'materialfield', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID'); |
||
|
1 ignored issue
–
show
|
|||
| 93 | new TableRelation('field', 'structurefield', 'FieldID'); |
||
| 94 | new TableRelation('field', 'structure', 'structurefield.StructureID'); |
||
| 95 | new TableRelation('structurefield', 'field', 'FieldID'); |
||
| 96 | new TableRelation('structurefield', 'materialfield', 'FieldID'); |
||
| 97 | new TableRelation('structurefield', 'material', 'materialfield.MaterialID'); |
||
| 98 | new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id', 'children_relations'); |
||
|
1 ignored issue
–
show
|
|||
| 99 | new TableRelation('structure', 'structure', 'children_relations.child_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'children'); |
||
|
1 ignored issue
–
show
|
|||
| 100 | new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'child_id', 'parents_relations'); |
||
|
1 ignored issue
–
show
|
|||
| 101 | new TableRelation('structure', 'structure', 'parents_relations.parent_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'parents'); |
||
|
1 ignored issue
–
show
|
|||
| 102 | new TableRelation('structurematerial', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id'); |
||
|
1 ignored issue
–
show
|
|||
| 103 | new TableRelation('groupright', 'right', 'RightID', TableRelation::T_ONE_TO_MANY); |
||
| 104 | //elapsed('CMS:prepare'); |
||
| 105 | |||
| 106 | // Все прошло успешно |
||
| 107 | return true && parent::prepare(); |
||
| 108 | } |
||
| 109 | |||
| 185 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: