@@ -11,13 +11,13 @@ |
||
11 | 11 | class Database { |
12 | 12 | private static $database; |
13 | 13 | |
14 | - public static function connect(array $connectionParams){ |
|
14 | + public static function connect(array $connectionParams) { |
|
15 | 15 | |
16 | - if(self::$database == null) |
|
16 | + if (self::$database == null) |
|
17 | 17 | { |
18 | 18 | $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams); |
19 | 19 | self::$database = new DB($connection); |
20 | - self::$database->setManagers(new TableManager(self::$database),new RecordManager(self::$database),new ModelManager(self::$database)); |
|
20 | + self::$database->setManagers(new TableManager(self::$database), new RecordManager(self::$database), new ModelManager(self::$database)); |
|
21 | 21 | return self::$database; |
22 | 22 | } |
23 | 23 |
@@ -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,7 +233,7 @@ discard block |
||
233 | 233 | * @param mixed|null $id |
234 | 234 | * @return mixed |
235 | 235 | */ |
236 | - public function get(String $table, mixed $id=null) : mixed |
|
236 | + public function get(String $table, mixed $id = null) : mixed |
|
237 | 237 | { |
238 | 238 | if (is_null($id)) { |
239 | 239 | return $this->recordManager->getAll($table); |
@@ -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 |
@@ -67,18 +67,18 @@ |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | - * Get single record by id |
|
71 | - * |
|
72 | - * @param \Scrawler\Arca\Model $model |
|
73 | - * @return \Scrawler\Arca\Model |
|
74 | - */ |
|
70 | + * Get single record by id |
|
71 | + * |
|
72 | + * @param \Scrawler\Arca\Model $model |
|
73 | + * @return \Scrawler\Arca\Model |
|
74 | + */ |
|
75 | 75 | public function getById(Model $model, mixed $id): Model |
76 | 76 | { |
77 | 77 | $qb = new QueryBuilder($this->db); |
78 | 78 | $query = $qb |
79 | - ->select('*') |
|
80 | - ->from($model->getName(), 't') |
|
81 | - ->where("t.id = '".$id."'"); |
|
79 | + ->select('*') |
|
80 | + ->from($model->getName(), 't') |
|
81 | + ->where("t.id = '".$id."'"); |
|
82 | 82 | $result = $this->db->connection->executeQuery($query)->fetchAssociative(); |
83 | 83 | $result = $result ? $result : []; |
84 | 84 | $model->setProperties($result)->setLoaded(); |
@@ -75,7 +75,7 @@ |
||
75 | 75 | public function getById(Model $model, mixed $id): Model |
76 | 76 | { |
77 | 77 | $qb = new QueryBuilder($this->db); |
78 | - $query = $qb |
|
78 | + $query = $qb |
|
79 | 79 | ->select('*') |
80 | 80 | ->from($model->getName(), 't') |
81 | 81 | ->where("t.id = '".$id."'"); |