@@ -21,14 +21,14 @@ |
||
| 21 | 21 | |
| 22 | 22 | protected function init() { |
| 23 | 23 | |
| 24 | - $this->addVirtual('gravatar', function (array $data) { |
|
| 24 | + $this->addVirtual('gravatar', function(array $data) { |
|
| 25 | 25 | |
| 26 | 26 | return md5(strtolower($data['email'])); |
| 27 | 27 | }); |
| 28 | 28 | |
| 29 | - $this->addVirtual('full_name', function (array $data) { |
|
| 29 | + $this->addVirtual('full_name', function(array $data) { |
|
| 30 | 30 | |
| 31 | - return trim($data['first_name'] . ' ' . $data['last_name']); |
|
| 31 | + return trim($data['first_name'].' '.$data['last_name']); |
|
| 32 | 32 | }); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -21,23 +21,23 @@ |
||
| 21 | 21 | |
| 22 | 22 | protected function init() { |
| 23 | 23 | |
| 24 | - $this->addVirtual('active', function (array $data) { |
|
| 24 | + $this->addVirtual('active', function(array $data) { |
|
| 25 | 25 | |
| 26 | 26 | return (($data['visibility'] === VISIBILITY_PUBLISHED) && !$data['locked']); |
| 27 | 27 | }); |
| 28 | 28 | |
| 29 | - $this->addVirtual('link', function (array $data) { |
|
| 29 | + $this->addVirtual('link', function(array $data) { |
|
| 30 | 30 | |
| 31 | 31 | if ('' === $data['slug']) return ''; |
| 32 | 32 | |
| 33 | - return (INSTALL_PATH . '/' . $data['slug']); |
|
| 33 | + return (INSTALL_PATH.'/'.$data['slug']); |
|
| 34 | 34 | }); |
| 35 | 35 | |
| 36 | - $this->addVirtual('canonical', function (array $data) { |
|
| 36 | + $this->addVirtual('canonical', function(array $data) { |
|
| 37 | 37 | |
| 38 | 38 | if ('' === $data['slug']) return ''; |
| 39 | 39 | |
| 40 | - return (Settings::get('system_url') . (($data['id'] !== 1) ? ('/' . $data['slug']) : '')); |
|
| 40 | + return (Settings::get('system_url').(($data['id'] !== 1) ? ('/'.$data['slug']) : '')); |
|
| 41 | 41 | }); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -28,14 +28,18 @@ |
||
| 28 | 28 | |
| 29 | 29 | $this->addVirtual('link', function (array $data) { |
| 30 | 30 | |
| 31 | - if ('' === $data['slug']) return ''; |
|
| 31 | + if ('' === $data['slug']) { |
|
| 32 | + return ''; |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | return (INSTALL_PATH . '/' . $data['slug']); |
| 34 | 36 | }); |
| 35 | 37 | |
| 36 | 38 | $this->addVirtual('canonical', function (array $data) { |
| 37 | 39 | |
| 38 | - if ('' === $data['slug']) return ''; |
|
| 40 | + if ('' === $data['slug']) { |
|
| 41 | + return ''; |
|
| 42 | + } |
|
| 39 | 43 | |
| 40 | 44 | return (Settings::get('system_url') . (($data['id'] !== 1) ? ('/' . $data['slug']) : '')); |
| 41 | 45 | }); |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | |
| 22 | 22 | protected function init() { |
| 23 | 23 | |
| 24 | - $this->addVirtual('link', function (array $data) { |
|
| 24 | + $this->addVirtual('link', function(array $data) { |
|
| 25 | 25 | |
| 26 | 26 | if ('' === $data['slug']) return ''; |
| 27 | 27 | |
| 28 | 28 | if (false !== Validate::url($data['slug'])) return $data['slug']; |
| 29 | 29 | |
| 30 | - return (INSTALL_PATH . '/' . $data['slug']); |
|
| 30 | + return (INSTALL_PATH.'/'.$data['slug']); |
|
| 31 | 31 | }); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -23,9 +23,13 @@ |
||
| 23 | 23 | |
| 24 | 24 | $this->addVirtual('link', function (array $data) { |
| 25 | 25 | |
| 26 | - if ('' === $data['slug']) return ''; |
|
| 26 | + if ('' === $data['slug']) { |
|
| 27 | + return ''; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | - if (false !== Validate::url($data['slug'])) return $data['slug']; |
|
| 30 | + if (false !== Validate::url($data['slug'])) { |
|
| 31 | + return $data['slug']; |
|
| 32 | + } |
|
| 29 | 33 | |
| 30 | 34 | return (INSTALL_PATH . '/' . $data['slug']); |
| 31 | 35 | }); |
@@ -37,9 +37,13 @@ |
||
| 37 | 37 | |
| 38 | 38 | public static function get(string $table, int $id = 0) : Entitizer\Utils\Entity { |
| 39 | 39 | |
| 40 | - if (!isset(self::$classes[$table])) throw new Exception\General(self::$error_message); |
|
| 40 | + if (!isset(self::$classes[$table])) { |
|
| 41 | + throw new Exception\General(self::$error_message); |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | - if (isset(self::$cache[$table][$id])) return self::$cache[$table][$id]; |
|
| 44 | + if (isset(self::$cache[$table][$id])) { |
|
| 45 | + return self::$cache[$table][$id]; |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | $entity = new self::$classes[$table]; $entity->init($id); |
| 45 | 49 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use Entitizer\Common\Page; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * Initialize the page by a slug |
|
| 19 | + * Initialize the page by a slug |
|
| 20 | 20 | * |
| 21 | 21 | * @return bool : true on success or false on failure |
| 22 | 22 | */ |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
| 41 | 41 | |
| 42 | - ("FROM " . static::$table . " ent ") . |
|
| 42 | + ("FROM " . static::$table . " ent ") . |
|
| 43 | 43 | |
| 44 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 44 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 45 | 45 | |
| 46 | - ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::get('rank') . " AND ") . |
|
| 46 | + ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::get('rank') . " AND ") . |
|
| 47 | 47 | |
| 48 | - ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
| 48 | + ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
| 49 | 49 | |
| 50 | 50 | # Select entity from DB |
| 51 | 51 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * Update slugs of the page descendants |
|
| 60 | + * Update slugs of the page descendants |
|
| 61 | 61 | * |
| 62 | 62 | * @return bool : true on success or false on failure |
| 63 | 63 | */ |
@@ -70,17 +70,17 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $query = ("UPDATE " . static::$table . " ent JOIN (") . |
| 72 | 72 | |
| 73 | - ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
| 73 | + ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
| 74 | 74 | |
| 75 | - ("FROM " . static::$table_relations . " rel ") . |
|
| 75 | + ("FROM " . static::$table_relations . " rel ") . |
|
| 76 | 76 | |
| 77 | - ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
| 77 | + ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
| 78 | 78 | |
| 79 | - ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
| 79 | + ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
| 80 | 80 | |
| 81 | - ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
| 81 | + ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
| 82 | 82 | |
| 83 | - (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
|
| 83 | + (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
|
| 84 | 84 | |
| 85 | 85 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
| 86 | 86 | |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | $query = ("UPDATE " . static::$table . " ent JOIN (") . |
| 90 | 90 | |
| 91 | - ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
| 91 | + ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
| 92 | 92 | |
| 93 | - ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
| 93 | + ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
| 94 | 94 | |
| 95 | - ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
| 95 | + ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
| 96 | 96 | |
| 97 | - ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
| 97 | + ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
| 98 | 98 | |
| 99 | - (") chk ON chk.id = ent.id SET ent.locked = 0"); |
|
| 99 | + (") chk ON chk.id = ent.id SET ent.locked = 0"); |
|
| 100 | 100 | |
| 101 | 101 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
| 102 | 102 | |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $selection = array_keys($this->definition->getParams()); |
| 35 | 35 | |
| 36 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
| 36 | + foreach ($selection as $key => $field) $selection[$key] = ('ent.'.$field); |
|
| 37 | 37 | |
| 38 | 38 | # Process query |
| 39 | 39 | |
| 40 | - $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
|
| 40 | + $query = ("SELECT ".implode(', ', $selection).", rel.ancestor as parent_id "). |
|
| 41 | 41 | |
| 42 | - ("FROM " . static::$table . " ent ") . |
|
| 42 | + ("FROM ".static::$table." ent "). |
|
| 43 | 43 | |
| 44 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 44 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
| 45 | 45 | |
| 46 | - ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::get('rank') . " AND ") . |
|
| 46 | + ("WHERE ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.access <= ".Auth::get('rank')." AND "). |
|
| 47 | 47 | |
| 48 | - ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
| 48 | + ("ent.locked = 0 AND ent.slug = '".addslashes($slug)."' LIMIT 1"); |
|
| 49 | 49 | |
| 50 | 50 | # Select entity from DB |
| 51 | 51 | |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | # Send lock/update request |
| 70 | 70 | |
| 71 | - $query = ("UPDATE " . static::$table . " ent JOIN (") . |
|
| 71 | + $query = ("UPDATE ".static::$table." ent JOIN ("). |
|
| 72 | 72 | |
| 73 | - ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
| 73 | + ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug "). |
|
| 74 | 74 | |
| 75 | - ("FROM " . static::$table_relations . " rel ") . |
|
| 75 | + ("FROM ".static::$table_relations." rel "). |
|
| 76 | 76 | |
| 77 | - ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
| 77 | + ("JOIN ".static::$table_relations." rls ON rls.descendant = rel.descendant "). |
|
| 78 | 78 | |
| 79 | - ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
| 79 | + ("JOIN ".static::$table." ens ON ens.id = rls.ancestor "). |
|
| 80 | 80 | |
| 81 | - ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
| 81 | + ("WHERE rel.ancestor = ".$this->id." GROUP BY rel.descendant"). |
|
| 82 | 82 | |
| 83 | 83 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
| 84 | 84 | |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | # Send unlock request |
| 88 | 88 | |
| 89 | - $query = ("UPDATE " . static::$table . " ent JOIN (") . |
|
| 89 | + $query = ("UPDATE ".static::$table." ent JOIN ("). |
|
| 90 | 90 | |
| 91 | - ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
| 91 | + ("SELECT rel.descendant as id FROM ".static::$table_relations." rel "). |
|
| 92 | 92 | |
| 93 | - ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
| 93 | + ("JOIN ".static::$table." enc ON enc.id = rel.descendant AND enc.locked = 1 "). |
|
| 94 | 94 | |
| 95 | - ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
| 95 | + ("LEFT JOIN ".static::$table." end ON end.id != enc.id AND end.slug = enc.slug "). |
|
| 96 | 96 | |
| 97 | - ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
| 97 | + ("WHERE end.id IS NULL GROUP BY rel.descendant"). |
|
| 98 | 98 | |
| 99 | 99 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
| 100 | 100 | |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function initBySlug(string $slug) : bool { |
| 25 | 25 | |
| 26 | - if (0 !== $this->id) return false; |
|
| 26 | + if (0 !== $this->id) { |
|
| 27 | + return false; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | # Process value |
| 29 | 31 | |
@@ -33,7 +35,9 @@ discard block |
||
| 33 | 35 | |
| 34 | 36 | $selection = array_keys($this->definition->getParams()); |
| 35 | 37 | |
| 36 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
| 38 | + foreach ($selection as $key => $field) { |
|
| 39 | + $selection[$key] = ('ent.' . $field); |
|
| 40 | + } |
|
| 37 | 41 | |
| 38 | 42 | # Process query |
| 39 | 43 | |
@@ -49,7 +53,9 @@ discard block |
||
| 49 | 53 | |
| 50 | 54 | # Select entity from DB |
| 51 | 55 | |
| 52 | - if (!(DB::send($query) && (DB::getLast()->rows === 1))) return false; |
|
| 56 | + if (!(DB::send($query) && (DB::getLast()->rows === 1))) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 53 | 59 | |
| 54 | 60 | # ------------------------ |
| 55 | 61 | |
@@ -64,7 +70,9 @@ discard block |
||
| 64 | 70 | |
| 65 | 71 | public function updateSlugs() : bool { |
| 66 | 72 | |
| 67 | - if (0 === $this->id) return false; |
|
| 73 | + if (0 === $this->id) { |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 68 | 76 | |
| 69 | 77 | # Send lock/update request |
| 70 | 78 | |
@@ -82,7 +90,9 @@ discard block |
||
| 82 | 90 | |
| 83 | 91 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
| 84 | 92 | |
| 85 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
| 93 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
| 94 | + return false; |
|
| 95 | + } |
|
| 86 | 96 | |
| 87 | 97 | # Send unlock request |
| 88 | 98 | |
@@ -98,7 +108,9 @@ discard block |
||
| 98 | 108 | |
| 99 | 109 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
| 100 | 110 | |
| 101 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
| 111 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 102 | 114 | |
| 103 | 115 | # ------------------------ |
| 104 | 116 | |
@@ -113,7 +125,9 @@ discard block |
||
| 113 | 125 | |
| 114 | 126 | public function create(array $data) : bool { |
| 115 | 127 | |
| 116 | - if (!parent::create($data)) return false; |
|
| 128 | + if (!parent::create($data)) { |
|
| 129 | + return false; |
|
| 130 | + } |
|
| 117 | 131 | |
| 118 | 132 | $this->updateSlugs(); |
| 119 | 133 | |
@@ -130,7 +144,9 @@ discard block |
||
| 130 | 144 | |
| 131 | 145 | public function edit(array $data) : bool { |
| 132 | 146 | |
| 133 | - if (!parent::edit($data)) return false; |
|
| 147 | + if (!parent::edit($data)) { |
|
| 148 | + return false; |
|
| 149 | + } |
|
| 134 | 150 | |
| 135 | 151 | $this->updateSlugs(); |
| 136 | 152 | |
@@ -147,7 +163,9 @@ discard block |
||
| 147 | 163 | |
| 148 | 164 | public function move(int $parent_id) : bool { |
| 149 | 165 | |
| 150 | - if (!parent::move($parent_id)) return false; |
|
| 166 | + if (!parent::move($parent_id)) { |
|
| 167 | + return false; |
|
| 168 | + } |
|
| 151 | 169 | |
| 152 | 170 | $this->updateSlugs(); |
| 153 | 171 | |
@@ -47,11 +47,11 @@ |
||
| 47 | 47 | |
| 48 | 48 | public function getStatement() : string { |
| 49 | 49 | |
| 50 | - return ("FOREIGN KEY (`" . $this->name . "`) REFERENCES `" . $this->table . "` (`" . $this->field . "`)") . |
|
| 50 | + return ("FOREIGN KEY (`".$this->name."`) REFERENCES `".$this->table."` (`".$this->field."`)"). |
|
| 51 | 51 | |
| 52 | - ((null !== $this->delete) ? (" ON DELETE " . $this->delete) : "") . |
|
| 52 | + ((null !== $this->delete) ? (" ON DELETE ".$this->delete) : ""). |
|
| 53 | 53 | |
| 54 | - ((null !== $this->update) ? (" ON UPDATE " . $this->update) : ""); |
|
| 54 | + ((null !== $this->update) ? (" ON UPDATE ".$this->update) : ""); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -36,9 +36,13 @@ |
||
| 36 | 36 | |
| 37 | 37 | $this->name = $name; $this->table = $table; $this->field = $field; |
| 38 | 38 | |
| 39 | - if (null !== $delete) $this->delete = $this->validateAction($delete); |
|
| 39 | + if (null !== $delete) { |
|
| 40 | + $this->delete = $this->validateAction($delete); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | - if (null !== $update) $this->update = $this->validateAction($update); |
|
| 43 | + if (null !== $update) { |
|
| 44 | + $this->update = $this->validateAction($update); |
|
| 45 | + } |
|
| 42 | 46 | } |
| 43 | 47 | |
| 44 | 48 | /** |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | return ("`" . $this->name . "` " . ($this->short ? "tiny" : "") . "int(" . $this->length . ")") . |
| 34 | 34 | |
| 35 | - (($this->unsigned ? " UNSIGNED" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
| 35 | + (($this->unsigned ? " UNSIGNED" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function getStatement() : string { |
| 32 | 32 | |
| 33 | - return ("`" . $this->name . "` " . ($this->short ? "tiny" : "") . "int(" . $this->length . ")") . |
|
| 33 | + return ("`".$this->name."` ".($this->short ? "tiny" : "")."int(".$this->length.")"). |
|
| 34 | 34 | |
| 35 | - (($this->unsigned ? " UNSIGNED" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
| 35 | + (($this->unsigned ? " UNSIGNED" : "")." NOT NULL DEFAULT '".$this->default."'"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function __construct(string $name, bool $short = false, int $length = 0, bool $unsigned = false, int $default = 0) { |
| 23 | 23 | |
| 24 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
| 24 | + foreach (get_defined_vars() as $name => $value) { |
|
| 25 | + $this->$name = $value; |
|
| 26 | + } |
|
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function getStatement() : string { |
| 32 | 32 | |
| 33 | - return ("`" . $this->name . "` tinyint(1) UNSIGNED NOT NULL DEFAULT '" . intval($this->default) . "'"); |
|
| 33 | + return ("`".$this->name."` tinyint(1) UNSIGNED NOT NULL DEFAULT '".intval($this->default)."'"); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function __construct(string $name, bool $default = false) { |
| 23 | 23 | |
| 24 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
| 24 | + foreach (get_defined_vars() as $name => $value) { |
|
| 25 | + $this->$name = $value; |
|
| 26 | + } |
|
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | /** |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->length . ")") : "text")) . |
| 34 | 34 | |
| 35 | - (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
| 35 | + (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function getStatement() : string { |
| 32 | 32 | |
| 33 | - return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->length . ")") : "text")) . |
|
| 33 | + return ("`".$this->name."` ".($this->short ? ("varchar(".$this->length.")") : "text")). |
|
| 34 | 34 | |
| 35 | - (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
| 35 | + (($this->binary ? " BINARY" : "")." NOT NULL DEFAULT '".$this->default."'"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function __construct(string $name, bool $short = true, int $length = 0, bool $binary = false, string $default = '') { |
| 23 | 23 | |
| 24 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
| 24 | + foreach (get_defined_vars() as $name => $value) { |
|
| 25 | + $this->$name = $value; |
|
| 26 | + } |
|
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | /** |