@@ -22,17 +22,17 @@ public function __construct($name, $config = null)
2222 $ datadir = $ config ->getPathValue ('datadir ' , 'data/ ' );
2323
2424 if (!is_dir ($ datadir )) {
25- throw new Exception ('Data directory [ ' . $ datadir . '] does not exist ' );
25+ throw new Exception ('Data directory [ ' . $ datadir .'] does not exist ' );
2626 } else if (!is_writable ($ datadir )) {
27- throw new Exception ('Data directory [ ' . $ datadir . '] is not writable ' );
27+ throw new Exception ('Data directory [ ' . $ datadir .'] is not writable ' );
2828 }
2929
30- $ sqllitedir = $ datadir . 'sqllite/ ' ;
30+ $ sqllitedir = $ datadir. 'sqllite/ ' ;
3131 if (!is_dir ($ sqllitedir )) {
3232 mkdir ($ sqllitedir );
3333 }
3434
35- $ dbfile = 'sqlite: ' . $ sqllitedir . $ name . '.sqlite ' ;
35+ $ dbfile = 'sqlite: ' . $ sqllitedir. $ name. '.sqlite ' ;
3636 if ($ this ->db = new \PDO ($ dbfile )) {
3737 $ q = @$ this ->db ->query ('SELECT key1 FROM data LIMIT 1 ' );
3838 if ($ q === false ) {
@@ -50,7 +50,7 @@ public function __construct($name, $config = null)
5050 ' );
5151 }
5252 } else {
53- throw new Exception ('Error creating SQL lite database [ ' . $ dbfile . ']. ' );
53+ throw new Exception ('Error creating SQL lite database [ ' . $ dbfile. ']. ' );
5454 }
5555 }
5656
@@ -67,7 +67,7 @@ private function insert($type, $key1, $key2, $value, $duration = null)
6767 {
6868 $ expire = is_null ($ duration ) ? null : (time () + $ duration );
6969
70- $ query = "INSERT INTO data (key1, key2, type, created, updated, expire, value) " .
70+ $ query = "INSERT INTO data (key1, key2, type, created, updated, expire, value) " .
7171 " VALUES(:key1, :key2, :type, :created, :updated, :expire, :value) " ;
7272 $ prepared = $ this ->db ->prepare ($ query );
7373 $ data = array (':key1 ' => $ key1 , ':key2 ' => $ key2 ,
@@ -96,7 +96,7 @@ private function update($type, $key1, $key2, $value, $duration = null)
9696 public function get ($ type = null , $ key1 = null , $ key2 = null )
9797 {
9898 $ conditions = self ::getCondition ($ type , $ key1 , $ key2 );
99- $ query = 'SELECT * FROM data WHERE ' . $ conditions ;
99+ $ query = 'SELECT * FROM data WHERE ' . $ conditions ;
100100
101101 $ prepared = $ this ->db ->prepare ($ query );
102102 $ prepared ->execute ();
@@ -135,7 +135,7 @@ public function exists($type, $key1, $key2)
135135 public function getList ($ type = null , $ key1 = null , $ key2 = null )
136136 {
137137 $ conditions = self ::getCondition ($ type , $ key1 , $ key2 );
138- $ query = 'SELECT * FROM data WHERE ' . $ conditions ;
138+ $ query = 'SELECT * FROM data WHERE ' . $ conditions ;
139139 $ prepared = $ this ->db ->prepare ($ query );
140140 $ prepared ->execute ();
141141
@@ -157,7 +157,7 @@ public function getKeys($type = null, $key1 = null, $key2 = null, $whichKey = 't
157157 }
158158
159159 $ conditions = self ::getCondition ($ type , $ key1 , $ key2 );
160- $ query = 'SELECT DISTINCT :whichKey FROM data WHERE ' . $ conditions ;
160+ $ query = 'SELECT DISTINCT :whichKey FROM data WHERE ' . $ conditions ;
161161 $ prepared = $ this ->db ->prepare ($ query );
162162 $ data = array ('whichKey ' => $ whichKey );
163163 $ prepared ->execute ($ data );
@@ -200,18 +200,17 @@ private function getCondition($type = null, $key1 = null, $key2 = null)
200200 {
201201 $ conditions = array ();
202202 if (!is_null ($ type )) {
203- $ conditions [] = "type = " . $ this ->db ->quote ($ type );
203+ $ conditions [] = "type = " . $ this ->db ->quote ($ type );
204204 }
205205 if (!is_null ($ key1 )) {
206- $ conditions [] = "key1 = " . $ this ->db ->quote ($ key1 );
206+ $ conditions [] = "key1 = " . $ this ->db ->quote ($ key1 );
207207 }
208208 if (!is_null ($ key2 )) {
209- $ conditions [] = "key2 = " . $ this ->db ->quote ($ key2 );
209+ $ conditions [] = "key2 = " . $ this ->db ->quote ($ key2 );
210210 }
211211 if (count ($ conditions ) === 0 ) {
212212 return '1 ' ;
213- }
214-
213+ }
215214 return join (' AND ' , $ conditions );
216215 }
217216}
0 commit comments