@@ -56,6 +56,9 @@ discard block |
||
56 | 56 | ->getJunctionClassName($classA, $classB); |
57 | 57 | } |
58 | 58 | |
59 | + /** |
|
60 | + * @param RecordWrapper $instance |
|
61 | + */ |
|
59 | 62 | public function getModelTable($instance) { |
60 | 63 | return$this->container->singleton(interfaces\TableNameResolverInterface::class) |
61 | 64 | ->getTableName($instance); |
@@ -66,6 +69,9 @@ discard block |
||
66 | 69 | ->getModelClassName($model, $context); |
67 | 70 | } |
68 | 71 | |
72 | + /** |
|
73 | + * @param string $class |
|
74 | + */ |
|
69 | 75 | public function getModelName($class) { |
70 | 76 | return $class; |
71 | 77 | } |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace ntentan\nibii; |
4 | 4 | |
5 | -use ntentan\panie\Container; |
|
6 | -use ntentan\kaikai\Cache; |
|
7 | 5 | use ntentan\atiaa\DbContext; |
6 | +use ntentan\kaikai\Cache; |
|
7 | +use ntentan\panie\Container; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * A collection of utility methods used as helpers for loading |
@@ -21,11 +21,11 @@ |
||
21 | 21 | $this->container = $container; |
22 | 22 | $this->dbContext = $container->resolve(DbContext::class); |
23 | 23 | $this->container->bind(interfaces\ModelJoinerInterface::class) |
24 | - ->to(Resolver::class); |
|
24 | + ->to(Resolver::class); |
|
25 | 25 | $this->container->bind(interfaces\TableNameResolverInterface::class) |
26 | - ->to(Resolver::class); |
|
26 | + ->to(Resolver::class); |
|
27 | 27 | $this->container->bind(interfaces\ModelClassResolverInterface::class) |
28 | - ->to(Resolver::class); |
|
28 | + ->to(Resolver::class); |
|
29 | 29 | $this->cache = $this->container->resolve(Cache::class); |
30 | 30 | self::$instance = $this; |
31 | 31 | } |
@@ -26,8 +26,6 @@ |
||
26 | 26 | |
27 | 27 | namespace ntentan\nibii; |
28 | 28 | |
29 | -use ntentan\atiaa\Db; |
|
30 | - |
|
31 | 29 | /** |
32 | 30 | * Description of DataOperations |
33 | 31 | * |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * |
43 | 43 | * |
44 | - * @param type $parameters |
|
44 | + * @param QueryParameters $parameters |
|
45 | 45 | * @return type |
46 | 46 | */ |
47 | 47 | public function select($parameters) { |
@@ -57,6 +57,9 @@ discard block |
||
57 | 57 | return $result; |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param QueryParameters $parameters |
|
62 | + */ |
|
60 | 63 | public function count($parameters) { |
61 | 64 | $result = $this->driver->query( |
62 | 65 | $this->getQueryEngine()->getCountQuery($parameters), $parameters->getBoundData() |
@@ -87,12 +90,18 @@ discard block |
||
87 | 90 | return $this->driver->query($this->updateQuery, $record); |
88 | 91 | } |
89 | 92 | |
93 | + /** |
|
94 | + * @param QueryParameters $parameters |
|
95 | + */ |
|
90 | 96 | public function bulkUpdate($data, $parameters) { |
91 | 97 | return $this->driver->query( |
92 | 98 | $this->getQueryEngine()->getBulkUpdateQuery($data, $parameters), array_merge($data, $parameters->getBoundData()) |
93 | 99 | ); |
94 | 100 | } |
95 | 101 | |
102 | + /** |
|
103 | + * @param QueryParameters $parameters |
|
104 | + */ |
|
96 | 105 | public function delete($parameters) { |
97 | 106 | return $this->driver->query( |
98 | 107 | $this->getQueryEngine()->getDeleteQuery($parameters), $parameters->getBoundData() |
@@ -119,6 +128,9 @@ discard block |
||
119 | 128 | return $this->queryEngine; |
120 | 129 | } |
121 | 130 | |
131 | + /** |
|
132 | + * @param RecordWrapper $model |
|
133 | + */ |
|
122 | 134 | public function setModel($model) { |
123 | 135 | $this->modelInstance = $model; |
124 | 136 | } |
@@ -2,9 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace ntentan\nibii; |
4 | 4 | |
5 | -use ntentan\utils\Text; |
|
6 | -use ntentan\atiaa\Db; |
|
7 | - |
|
8 | 5 | /** |
9 | 6 | * A DriverAdaptr is a generic database adapter. |
10 | 7 | * This adapter implements a lot of its operations through the atiaa library. |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace ntentan\nibii; |
4 | 4 | |
5 | -use ntentan\atiaa\Db; |
|
6 | - |
|
7 | 5 | class ModelDescription { |
8 | 6 | |
9 | 7 | private $fields = []; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | /** |
52 | 52 | * |
53 | 53 | * @param RecordWrapper $wrapper |
54 | - * @param DataAdapter $adapter |
|
54 | + * @param DriverAdapter $adapter |
|
55 | 55 | * @param DataOperations $dataOperations |
56 | 56 | */ |
57 | 57 | public function __construct(Context $context, RecordWrapper $wrapper, DriverAdapter $adapter, $dataOperations) { |
@@ -27,8 +27,6 @@ |
||
27 | 27 | namespace ntentan\nibii; |
28 | 28 | |
29 | 29 | use ntentan\utils\Text; |
30 | -use ntentan\atiaa\Db; |
|
31 | -use ntentan\panie\Container; |
|
32 | 30 | |
33 | 31 | class QueryOperations { |
34 | 32 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | /** |
24 | 24 | * |
25 | - * @param \ $model |
|
25 | + * @param string $table |
|
26 | 26 | */ |
27 | 27 | public function __construct($table) { |
28 | 28 | $this->table = $table; |
@@ -104,6 +104,9 @@ discard block |
||
104 | 104 | $this->boundData += $values; |
105 | 105 | } |
106 | 106 | |
107 | + /** |
|
108 | + * @param boolean $firstOnly |
|
109 | + */ |
|
107 | 110 | public function setFirstOnly($firstOnly) { |
108 | 111 | $this->firstOnly = $firstOnly; |
109 | 112 | return $this; |
@@ -121,6 +124,9 @@ discard block |
||
121 | 124 | $this->offset = $offset; |
122 | 125 | } |
123 | 126 | |
127 | + /** |
|
128 | + * @param string $field |
|
129 | + */ |
|
124 | 130 | public function addSort($field, $direction = 'ASC') { |
125 | 131 | $this->sorts[] = "$field $direction"; |
126 | 132 | } |
@@ -26,9 +26,7 @@ |
||
26 | 26 | |
27 | 27 | namespace ntentan\nibii; |
28 | 28 | |
29 | -use ntentan\kaikai\Cache; |
|
30 | 29 | use ntentan\utils\Text; |
31 | -use ntentan\atiaa\Db; |
|
32 | 30 | |
33 | 31 | /** |
34 | 32 | * |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $this->quotedTable = $driver->quoteIdentifier($table); |
65 | 65 | $this->table = $this->unquotedTable = $table; |
66 | 66 | } else { |
67 | - $this->quotedTable = ( isset($table['schema']) ? "{$driver->quoteIdentifier($table["schema"])}." : "") . $driver->quoteIdentifier($table["table"]); |
|
68 | - $this->unquotedTable = (isset($table['schema']) ? "{$table['schema']}." : "") . $table['table']; |
|
67 | + $this->quotedTable = (isset($table['schema']) ? "{$driver->quoteIdentifier($table["schema"])}." : "").$driver->quoteIdentifier($table["table"]); |
|
68 | + $this->unquotedTable = (isset($table['schema']) ? "{$table['schema']}." : "").$table['table']; |
|
69 | 69 | $this->table = $table['table']; |
70 | 70 | $this->schema = $table['schema']; |
71 | 71 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function getDescription() { |
85 | 85 | return $this->context->getCache()->read( |
86 | - (new \ReflectionClass($this))->getName() . '::desc', function() { |
|
86 | + (new \ReflectionClass($this))->getName().'::desc', function() { |
|
87 | 87 | return $this->container->resolve(ModelDescription::class, ['model' => $this]); |
88 | 88 | } |
89 | 89 | ); |
@@ -26,8 +26,6 @@ |
||
26 | 26 | |
27 | 27 | namespace ntentan\nibii; |
28 | 28 | |
29 | -use ntentan\panie\InjectionContainer; |
|
30 | - |
|
31 | 29 | abstract class Relationship { |
32 | 30 | |
33 | 31 | const BELONGS_TO = 'BelongsTo'; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | $this->options['foreign_key'] = $model->getDescription()->getPrimaryKey()[0]; |
54 | 54 | } |
55 | 55 | if ($this->options['local_key'] == null) { |
56 | - $this->options['local_key'] = Text::singularize($table) . '_id'; |
|
56 | + $this->options['local_key'] = Text::singularize($table).'_id'; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 |