Skip to content

Commit a3b0ee8

Browse files
committed
split up setPrepare, update tests for change
1 parent 966ca7d commit a3b0ee8

File tree

11 files changed

+42
-30
lines changed

11 files changed

+42
-30
lines changed

lib/ez_sql_mysqli.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,7 @@ function ($string, &$arg) use (&$params) {
325325
// free and closes a prepared statement
326326
$stmt->free_result();
327327
$stmt->close();
328-
329-
$this->clearPrepare();
330-
328+
331329
return $result;
332330
}
333331

@@ -337,7 +335,7 @@ function ($string, &$arg) use (&$params) {
337335
* @param type $query
338336
* @return boolean
339337
*/
340-
public function query($query, $use_prepare=false) {
338+
public function query($query, $use_prepare = false) {
341339
$param = [];
342340
if ($use_prepare)
343341
$param = $this->prepareValues();

shared/ezQuery.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,17 @@ protected function clearPrepare()
135135
public function setPrepare($on = true)
136136
{
137137
$this->prepareActive = ($on) ? true : false;
138-
}
138+
}
139+
140+
public function prepareActive()
141+
{
142+
$this->prepareActive = true;
143+
}
144+
145+
public function prepareInActive()
146+
{
147+
$this->prepareActive = $this->clearPrepare();
148+
}
139149

140150
/**
141151
* Convert array to string, and attach '`, `' for separation, if none is provided.

shared/ezQueryInterface.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ interface ezQueryInterface
3636
public static function clean($string);
3737

3838
/**
39-
* Turn off/on prepare function availability in ezQuery shortcut method calls
40-
*/
41-
public function setPrepare($on = true);
39+
* Turn on prepare function availability in ezQuery shortcut method calls
40+
*/
41+
public function prepareActive();
4242

43+
/**
44+
* Turn off prepare function availability in ezQuery shortcut method calls
45+
*/
46+
public function prepareInActive();
4347

4448
/**
4549
* Specifies a grouping over the results of the query.

tests/mysqli/ezSQL_mysqliTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function setUp() {
7979
);
8080
}
8181
$this->object = new ezSQL_mysqli();
82-
$this->object->setPrepare();
82+
$this->object->prepareActive();
8383
}
8484

8585
/**
@@ -293,11 +293,11 @@ public function testCreate()
293293
primary('id_pk', 'id')),
294294
0);
295295

296-
$this->object->setPrepare(false);
296+
$this->object->prepareInActive(false);
297297
$this->assertEquals($this->object->insert('new_create_test',
298298
['create_key' => 'test 2']),
299299
1);
300-
$this->object->setPrepare();
300+
$this->object->prepareActive();
301301
}
302302

303303
/**
@@ -472,7 +472,7 @@ public function testWhere()
472472
{
473473
$this->object->connect(self::TEST_DB_USER, self::TEST_DB_PASSWORD);
474474
$this->object->select(self::TEST_DB_NAME);
475-
$this->object->setPrepare(false);
475+
$this->object->prepareInActive(false);
476476
$expect = where(
477477
between('where_test','testing 1','testing 2','bad'),
478478
like('test_null','null')
@@ -507,7 +507,7 @@ public function testWhere()
507507
array('where_test','=','testing 1','or'),
508508
array('test_like',_LIKE,'_good')
509509
));
510-
$this->object->setPrepare(true);
510+
$this->object->prepareActive(true);
511511
$expect = where(
512512
between('where_test','testing 1','testing 2','bad'),
513513
like('test_null','null')

tests/pdo/ezSQL_pdo_mysqlTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function setUp() {
9494
);
9595
}
9696
$this->object = new ezSQL_pdo();
97-
$this->object->setPrepare();
97+
$this->object->prepareActive();
9898
} // setUp
9999

100100
/**
@@ -179,7 +179,7 @@ public function testSecurePDO()
179179
primary('id_pk', 'id')),
180180
0);
181181

182-
$this->object->setPrepare(false);
182+
$this->object->prepareInActive(false);
183183
$this->assertEquals($this->object->insert('new_create_test2',
184184
['create_key' => 'test 2']),
185185
1);
@@ -188,7 +188,7 @@ public function testSecurePDO()
188188
$res = $conn->query("SHOW STATUS LIKE 'Ssl_cipher';")->fetchAll();
189189
$this->assertEquals('Ssl_cipher', $res[0]['Variable_name']);
190190

191-
$this->object->setPrepare();
191+
$this->object->prepareActive();
192192
$this->assertEquals($this->object->drop('new_create_test2'), 0);
193193
}
194194

@@ -205,11 +205,11 @@ public function testCreate()
205205
primary('id_pk', 'id')),
206206
0);
207207

208-
$this->object->setPrepare(false);
208+
$this->object->prepareInActive(false);
209209
$this->assertEquals($this->object->insert('new_create_test',
210210
['create_key' => 'test 2']),
211211
1);
212-
$this->object->setPrepare();
212+
$this->object->prepareActive();
213213
}
214214

215215
/**

tests/pdo/ezSQL_pdo_pgsqlTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function setUp() {
9494
);
9595
}
9696
$this->object = new ezSQL_pdo();
97-
$this->object->setPrepare();
97+
$this->object->prepareActive();
9898
} // setUp
9999

100100
/**

tests/pdo/ezSQL_pdo_sqliteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function setUp() {
9090
);
9191
}
9292
$this->object = new ezSQL_pdo();
93-
$this->object->setPrepare();
93+
$this->object->prepareActive();
9494
} // setUp
9595

9696
/**

tests/pdo/ezSQL_pdo_sqlsrvTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function setUp() {
7979
);
8080
}
8181
$this->object = new ezSQL_pdo();
82-
$this->object->setPrepare();
82+
$this->object->prepareActive();
8383
} // setUp
8484

8585
/**

tests/postgresql/ezSQL_postgresqlTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function setUp() {
7777
);
7878
}
7979
$this->object = new ezSQL_postgresql;
80-
$this->object->setPrepare();
80+
$this->object->prepareActive();
8181
} // setUp
8282

8383
/**
@@ -195,11 +195,11 @@ public function testCreate()
195195
primary('id_pk', 'id')),
196196
0);
197197

198-
$this->object->setPrepare(false);
198+
$this->object->prepareInActive(false);
199199
$this->assertEquals($this->object->insert('new_create_test',
200200
['create_key' => 'test 2']),
201201
1);
202-
$this->object->setPrepare();
202+
$this->object->prepareActive();
203203
}
204204

205205
/**

tests/sqlite/ezSQL_sqlite3Test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function setUp()
4949
);
5050
}
5151
$this->object = new ezSQL_sqlite3(self::TEST_SQLITE_DB_DIR, self::TEST_SQLITE_DB);
52-
$this->object->setPrepare();
52+
$this->object->prepareActive();
5353
}
5454

5555
/**
@@ -138,11 +138,11 @@ public function testCreate()
138138
primary('id_pk', 'id')),
139139
0);
140140

141-
$this->object->setPrepare(false);
141+
$this->object->prepareInActive(false);
142142
$this->assertEquals($this->object->insert('new_create_test',
143143
['create_key' => 'test 2']),
144144
0);
145-
$this->object->setPrepare();
145+
$this->object->prepareActive();
146146
}
147147

148148
/**

0 commit comments

Comments
 (0)