@@ -58,7 +58,7 @@ |
||
| 58 | 58 | { |
| 59 | 59 | $table = new Table($model->getName()); |
| 60 | 60 | if ($this->db->isUsingUUID()) { |
| 61 | - $table->addColumn('id', 'string', ['length' => 36, 'notnull' => true,]); |
|
| 61 | + $table->addColumn('id', 'string', ['length' => 36, 'notnull' => true, ]); |
|
| 62 | 62 | } else { |
| 63 | 63 | $table->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true)); |
| 64 | 64 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | private string $table; |
| 8 | 8 | private Database $db; |
| 9 | 9 | |
| 10 | - public function __construct(Database $db){ |
|
| 10 | + public function __construct(Database $db) { |
|
| 11 | 11 | $this->db = $db; |
| 12 | 12 | parent::__construct($this->db->connection); |
| 13 | 13 | |
@@ -12,12 +12,12 @@ |
||
| 12 | 12 | * Create RecordManager |
| 13 | 13 | * @param \Scrawler\Arca\Database $db |
| 14 | 14 | */ |
| 15 | - public function __construct(Database $db){ |
|
| 15 | + public function __construct(Database $db) { |
|
| 16 | 16 | $this->db = $db; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function create(string $name){ |
|
| 20 | - return new Model($name,$this->db); |
|
| 19 | + public function create(string $name) { |
|
| 20 | + return new Model($name, $this->db); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __set(string $key, mixed $val): void |
| 34 | 34 | { |
| 35 | - $this->set($key,$val); |
|
| 35 | + $this->set($key, $val); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function set(string $key,mixed $val): void |
|
| 38 | + public function set(string $key, mixed $val): void |
|
| 39 | 39 | { |
| 40 | 40 | //bug: fix issue with bool storage |
| 41 | 41 | if (gettype($val) == 'boolean') { |
@@ -73,23 +73,23 @@ discard block |
||
| 73 | 73 | return $this->get($key); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function get(string $key){ |
|
| 76 | + public function get(string $key) { |
|
| 77 | 77 | |
| 78 | 78 | if (preg_match('/[A-Z]/', $key)) { |
| 79 | 79 | $parts = preg_split('/(?=[A-Z])/', $key, -1, PREG_SPLIT_NO_EMPTY); |
| 80 | 80 | if (strtolower($parts[0]) == 'own') { |
| 81 | - if (strtolower($parts[2]) == 'list') { |
|
| 82 | - return $this->db->find(strtolower($parts[1]))->where($this->getName() . '_id = "' . $this->_id.'"')->get(); |
|
| 81 | + if (strtolower($parts[2]) == 'list') { |
|
| 82 | + return $this->db->find(strtolower($parts[1]))->where($this->getName().'_id = "'.$this->_id.'"')->get(); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | if (strtolower($parts[0]) == 'shared') { |
| 86 | - if (strtolower($parts[2]) == 'list') { |
|
| 86 | + if (strtolower($parts[2]) == 'list') { |
|
| 87 | 87 | $rel_table = $this->db->getTableManager()->tableExists($this->table.'_'.strtolower($parts[1])) ? $this->table.'_'.strtolower($parts[1]) : strtolower($parts[1]).'_'.$this->table; |
| 88 | - $relations = $this->db->find($rel_table)->where($this->getName() . '_id = "' . $this->_id.'"')->get(); |
|
| 88 | + $relations = $this->db->find($rel_table)->where($this->getName().'_id = "'.$this->_id.'"')->get(); |
|
| 89 | 89 | $rel_ids = ''; |
| 90 | 90 | foreach ($relations as $relation) { |
| 91 | - $key = strtolower($parts[1]) . '_id'; |
|
| 92 | - $rel_ids .= "'".$relation->$key . "',"; |
|
| 91 | + $key = strtolower($parts[1]).'_id'; |
|
| 92 | + $rel_ids .= "'".$relation->$key."',"; |
|
| 93 | 93 | } |
| 94 | 94 | $rel_ids = substr($rel_ids, 0, -1); |
| 95 | 95 | return $this->db->find(strtolower($parts[1]))->where('id IN ('.$rel_ids.')')->get(); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function setManagers(TableManager $tableManager, RecordManager $recordManager, ModelManager $modelManager){ |
|
| 30 | + public function setManagers(TableManager $tableManager, RecordManager $recordManager, ModelManager $modelManager) { |
|
| 31 | 31 | $this->tableManager = $tableManager; |
| 32 | 32 | $this->recordManager = $recordManager; |
| 33 | 33 | $this->modelManager = $modelManager; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param array $params |
| 42 | 42 | * @return integer |
| 43 | 43 | */ |
| 44 | - public function exec(string $sql, array $params=array()): int |
|
| 44 | + public function exec(string $sql, array $params = array()): int |
|
| 45 | 45 | { |
| 46 | 46 | return $this->connection->executeStatement($sql, $params); |
| 47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param array $params |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - public function getAll(string $sql, array $params=[]): array |
|
| 56 | + public function getAll(string $sql, array $params = []): array |
|
| 57 | 57 | { |
| 58 | 58 | return $this->connection->executeQuery($sql, $params)->fetchAllAssociative(); |
| 59 | 59 | } |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | * @param mixed|null $id |
| 234 | 234 | * @return mixed |
| 235 | 235 | */ |
| 236 | - public function get(String $table,mixed $id = null) : Model|Collection |
|
| 236 | + public function get(String $table, mixed $id = null) : Model | Collection |
|
| 237 | 237 | { |
| 238 | 238 | // For backward compatibility reason |
| 239 | - if($id != null){ |
|
| 240 | - return $this->getOne($table,$id); |
|
| 239 | + if ($id != null) { |
|
| 240 | + return $this->getOne($table, $id); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | return $this->recordManager->getAll($table); |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function getById(Model $model, mixed $id): Model |
| 76 | 76 | { |
| 77 | - $query = (new QueryBuilder($this->db)) |
|
| 77 | + $query = (new QueryBuilder($this->db)) |
|
| 78 | 78 | ->select('*') |
| 79 | 79 | ->from($model->getName(), 't') |
| 80 | 80 | ->where("t.id = '".$id."'"); |