Skip to content

Commit bd21e8a

Browse files
committed
Revert "BC, renamed ezsqlModel class properties that was accessible with get/set, now PSR 1 camelCase"
This reverts commit 7addf37.
1 parent 9b91512 commit bd21e8a

File tree

9 files changed

+266
-277
lines changed

9 files changed

+266
-277
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ test.php
1616
*.crt
1717
*.cache
1818
tmp
19-
.rnd

lib/Database/ez_mysqli.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ez_mysqli extends ezsqlModel implements DatabaseInterface
1313
{
1414
private $return_val = 0;
1515
private $is_insert = false;
16+
private $shortcutUsed = false;
1617
private $isTransactional = false;
1718

1819
/**
@@ -32,7 +33,6 @@ class ez_mysqli extends ezsqlModel implements DatabaseInterface
3233
* @var ConfigInterface
3334
*/
3435
private $database;
35-
protected $shortcutUsed = false;
3636

3737
public function __construct(ConfigInterface $settings = null)
3838
{
@@ -124,7 +124,7 @@ public function connect(
124124
} // connect
125125

126126
/**
127-
* Try to select the default database for mySQL
127+
* Try to select a mySQL database
128128
*
129129
* @param string $name The name of the database
130130
* @param string $charset Encoding of the database
@@ -212,9 +212,9 @@ private function fetch_prepared_result(&$stmt, $query)
212212
if (\preg_match("/^(insert|delete|update|replace)\s+/i", $query)) {
213213
$this->_affectedRows = \mysqli_stmt_affected_rows($stmt);
214214

215-
// Take note of the insert id
215+
// Take note of the insert_id
216216
if (\preg_match("/^(insert|replace)\s+/i", $query)) {
217-
$this->insertId = $stmt->insert_id;
217+
$this->insert_id = $stmt->insert_id;
218218
}
219219
} else {
220220
$this->_affectedRows = $stmt->num_rows;
@@ -225,7 +225,7 @@ private function fetch_prepared_result(&$stmt, $query)
225225
while ($field = $meta->fetch_field()) {
226226
$col_info[$field->name] = "";
227227
$variables[$field->name] = &$col_info[$field->name];
228-
$this->colInfo[$x] = $field;
228+
$this->col_info[$x] = $field;
229229
$x++;
230230
}
231231

@@ -240,7 +240,7 @@ private function fetch_prepared_result(&$stmt, $query)
240240
foreach ($variables as $key => $value) {
241241
$resultObject->$key = $value;
242242
}
243-
$this->lastResult[$i] = $resultObject;
243+
$this->last_result[$i] = $resultObject;
244244
$i++;
245245
}
246246
}
@@ -251,7 +251,7 @@ private function fetch_prepared_result(&$stmt, $query)
251251
$this->register_error($str);
252252

253253
// If debug ALL queries
254-
$this->trace || $this->debugAll ? $this->debug() : null;
254+
$this->trace || $this->debug_all ? $this->debug() : null;
255255
return false;
256256
}
257257

@@ -262,7 +262,7 @@ private function fetch_prepared_result(&$stmt, $query)
262262
$this->store_cache($query, $is_insert);
263263

264264
// If debug ALL queries
265-
$this->trace || $this->debugAll ? $this->debug() : null;
265+
$this->trace || $this->debug_all ? $this->debug() : null;
266266

267267
return $return_val;
268268
}
@@ -282,7 +282,7 @@ public function query_prepared(string $query, array $param = null)
282282
$stmt = $this->dbh->prepare($query);
283283
if (!$stmt instanceof \mysqli_stmt) {
284284
if ($this->isTransactional)
285-
throw new \Exception($this->lastError);
285+
throw new \Exception($this->getLast_Error());
286286

287287
return false;
288288
}
@@ -338,7 +338,7 @@ private function processQueryResult(string $query, $result = null)
338338
$this->register_error($str);
339339

340340
// If debug ALL queries
341-
$this->trace || $this->debugAll ? $this->debug() : null;
341+
$this->trace || $this->debug_all ? $this->debug() : null;
342342
return false;
343343
}
344344

@@ -350,7 +350,7 @@ private function processQueryResult(string $query, $result = null)
350350

351351
// Take note of the insert_id
352352
if (\preg_match("/^(insert|replace)\s+/i", $query)) {
353-
$this->insertId = \mysqli_insert_id($this->dbh);
353+
$this->insert_id = \mysqli_insert_id($this->dbh);
354354
}
355355

356356
// Return number of rows affected
@@ -362,25 +362,25 @@ private function processQueryResult(string $query, $result = null)
362362
// Take note of column info
363363
$i = 0;
364364
while ($i < \mysqli_num_fields($this->result)) {
365-
$this->colInfo[$i] = \mysqli_fetch_field($this->result);
365+
$this->col_info[$i] = \mysqli_fetch_field($this->result);
366366
$i++;
367367
}
368368

369369
// Store Query Results
370370
$num_rows = 0;
371371
while ($row = \mysqli_fetch_object($this->result)) {
372372
// Store results as an objects within main array
373-
$this->lastResult[$num_rows] = $row;
373+
$this->last_result[$num_rows] = $row;
374374
$num_rows++;
375375
}
376376

377377
\mysqli_free_result($this->result);
378378

379379
// Log number of rows the query returned
380-
$this->numRows = $num_rows;
380+
$this->num_rows = $num_rows;
381381

382382
// Return number of rows selected
383-
$this->return_val = $this->numRows;
383+
$this->return_val = $this->num_rows;
384384
}
385385
}
386386
}
@@ -414,10 +414,10 @@ public function query(string $query, bool $use_prepare = false)
414414
$this->log_query("\$db->query(\"$query\")");
415415

416416
// Keep track of the last query for debug..
417-
$this->lastQuery = $query;
417+
$this->last_query = $query;
418418

419419
// Count how many queries there have been
420-
$this->numQueries++;
420+
$this->num_queries++;
421421

422422
// Use core file cache function
423423
if ($cache = $this->get_cache($query)) {
@@ -440,7 +440,7 @@ public function query(string $query, bool $use_prepare = false)
440440

441441
if ($this->processQueryResult($query) === false) {
442442
if ($this->isTransactional)
443-
throw new \Exception($this->lastError);
443+
throw new \Exception($this->getLast_Error());
444444

445445
return false;
446446
}
@@ -449,7 +449,7 @@ public function query(string $query, bool $use_prepare = false)
449449
$this->store_cache($query, $this->is_insert);
450450

451451
// If debug ALL queries
452-
$this->trace || $this->debugAll ? $this->debug() : null;
452+
$this->trace || $this->debug_all ? $this->debug() : null;
453453

454454
return $this->return_val;
455455
} // query
@@ -514,7 +514,7 @@ public function getCharset()
514514
}
515515

516516
/**
517-
* Returns the last inserted Id - auto generated
517+
* Returns the last inserted auto-increment
518518
*
519519
* @return int
520520
*/
@@ -530,7 +530,7 @@ public function beginTransaction()
530530
{
531531
/* turn autocommit off */
532532
$this->dbh->autocommit(false);
533-
$this->dbh->begin_transaction(\MYSQLI_TRANS_START_READ_WRITE);
533+
$this->dbh->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
534534
$this->isTransactional = true;
535535
}
536536

lib/Database/ez_pdo.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function catch_error()
221221

222222
$error_str = \substr($error_str, 0, -2);
223223

224-
$this->register_error($error_str . ' ' . $this->lastQuery);
224+
$this->register_error($error_str . ' ' . $this->last_query);
225225

226226
return true;
227227
}
@@ -246,14 +246,14 @@ public function query_prepared(string $query, array $param = null, $isSelect = f
246246
try {
247247
while ($row = @$stmt->fetch(\PDO::FETCH_ASSOC)) {
248248
// Store results as an objects within main array
249-
$this->lastResult[$num_rows] = (object) $row;
249+
$this->last_result[$num_rows] = (object) $row;
250250
$num_rows++;
251251
}
252252
} catch (\Throwable $ex) {
253253
//
254254
}
255255

256-
$this->numRows = $num_rows;
256+
$this->num_rows = $num_rows;
257257
}
258258

259259
$return = ($isSelect) ? $stmt : $result;
@@ -289,16 +289,16 @@ private function processResult(string $query, $result = null, bool $isSelect = f
289289
$col_count = $result->columnCount();
290290
for ($i = 0; $i < $col_count; $i++) {
291291
// Start DEBUG by psc!
292-
$this->colInfo[$i] = new \stdClass();
292+
$this->col_info[$i] = new \stdClass();
293293
// End DEBUG by psc
294294
if ($meta = $result->getColumnMeta($i)) {
295-
$this->colInfo[$i]->name = $meta['name'];
296-
$this->colInfo[$i]->type = $meta['native_type'];
297-
$this->colInfo[$i]->max_length = '';
295+
$this->col_info[$i]->name = $meta['name'];
296+
$this->col_info[$i]->type = $meta['native_type'];
297+
$this->col_info[$i]->max_length = '';
298298
} else {
299-
$this->colInfo[$i]->name = 'undefined';
300-
$this->colInfo[$i]->type = 'undefined';
301-
$this->colInfo[$i]->max_length = '';
299+
$this->col_info[$i]->name = 'undefined';
300+
$this->col_info[$i]->type = 'undefined';
301+
$this->col_info[$i]->max_length = '';
302302
}
303303
}
304304

@@ -307,18 +307,18 @@ private function processResult(string $query, $result = null, bool $isSelect = f
307307
try {
308308
while ($row = @$result->fetch(\PDO::FETCH_ASSOC)) {
309309
// Store results as an objects within main array
310-
$this->lastResult[$num_rows] = (object) $row;
310+
$this->last_result[$num_rows] = (object) $row;
311311
$num_rows++;
312312
}
313313
} catch (\Throwable $ex) {
314314
//
315315
}
316316

317317
// Log number of rows the query returned
318-
$this->numRows = empty($num_rows) ? $this->numRows : $num_rows;
318+
$this->num_rows = empty($num_rows) ? $this->num_rows : $num_rows;
319319

320320
// Return number of rows selected
321-
$this->return_val = $this->numRows;
321+
$this->return_val = $this->num_rows;
322322
}
323323
} else {
324324
$this->is_insert = true;
@@ -329,7 +329,7 @@ private function processResult(string $query, $result = null, bool $isSelect = f
329329
try {
330330
// Take note of the insert_id
331331
if (\preg_match("/^(insert|replace)\s+/i", $query)) {
332-
$this->insertId = @$this->dbh->lastInsertId();
332+
$this->insert_id = @$this->dbh->lastInsertId();
333333
}
334334
} catch (\Throwable $ex) {
335335
//
@@ -417,21 +417,21 @@ public function query(string $query, bool $use_prepare = false)
417417
$this->log_query("\$db->query(\"$query\")");
418418

419419
// Keep track of the last query for debug..
420-
$this->lastQuery = $query;
420+
$this->last_query = $query;
421421

422-
$this->numQueries++;
422+
$this->num_queries++;
423423

424424
// Start timer
425-
$this->timer_start($this->numQueries);
425+
$this->timer_start($this->num_queries);
426426

427427
// Use core file cache function
428428
if ($cache = $this->get_cache($query)) {
429429
// Keep tack of how long all queries have taken
430-
$this->timer_update_global($this->numQueries);
430+
$this->timer_update_global($this->num_queries);
431431

432432
// Trace all queries
433-
if ($this->useTraceLog) {
434-
$this->traceLog[] = $this->debug(false);
433+
if ($this->use_trace_log) {
434+
$this->trace_log[] = $this->debug(false);
435435
}
436436

437437
return $cache;
@@ -459,14 +459,14 @@ public function query(string $query, bool $use_prepare = false)
459459
$this->store_cache($query, $this->is_insert);
460460

461461
// If debug ALL queries
462-
$this->trace || $this->debugAll ? $this->debug() : null;
462+
$this->trace || $this->debug_all ? $this->debug() : null;
463463

464464
// Keep tack of how long all queries have taken
465-
$this->timer_update_global($this->numQueries);
465+
$this->timer_update_global($this->num_queries);
466466

467467
// Trace all queries
468-
if ($this->useTraceLog) {
469-
$this->traceLog[] = $this->debug(false);
468+
if ($this->use_trace_log) {
469+
$this->trace_log[] = $this->debug(false);
470470
}
471471

472472
return $this->return_val;

lib/Database/ez_pgsql.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function connect(
103103
$connect_string = "host=" . $host . " port=" . $port . " dbname=" . $name . " user=" . $user . " password=" . $password;
104104

105105
// Try to establish the server database handle
106-
if (!$this->dbh = \pg_connect($connect_string, \PGSQL_CONNECT_FORCE_NEW)) {
106+
if (!$this->dbh = \pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW)) {
107107
$this->register_error(\FAILED_CONNECTION . ' in ' . __FILE__ . ' on line ' . __LINE__);
108108
} else {
109109
$this->_connected = true;
@@ -189,7 +189,7 @@ private function processQueryResult(string $query, $result = null)
189189
// Thx. Rafael Bernal
190190
$insert_query = \pg_query("SELECT lastval();");
191191
$insert_row = \pg_fetch_row($insert_query);
192-
$this->insertId = $insert_row[0];
192+
$this->insert_id = $insert_row[0];
193193
}
194194

195195
// Return number for rows affected
@@ -209,10 +209,10 @@ private function processQueryResult(string $query, $result = null)
209209
// Take note of column info
210210
$i = 0;
211211
while ($i < @\pg_num_fields($this->result)) {
212-
$this->colInfo[$i] = new \stdClass();
213-
$this->colInfo[$i]->name = \pg_field_name($this->result, $i);
214-
$this->colInfo[$i]->type = \pg_field_type($this->result, $i);
215-
$this->colInfo[$i]->size = \pg_field_size($this->result, $i);
212+
$this->col_info[$i] = new \stdClass();
213+
$this->col_info[$i]->name = \pg_field_name($this->result, $i);
214+
$this->col_info[$i]->type = \pg_field_type($this->result, $i);
215+
$this->col_info[$i]->size = \pg_field_size($this->result, $i);
216216
$i++;
217217
}
218218

@@ -223,17 +223,17 @@ private function processQueryResult(string $query, $result = null)
223223
*/
224224
while ($row = @\pg_fetch_object($this->result)) {
225225
// Store results as an objects within main array
226-
$this->lastResult[$num_rows] = $row;
226+
$this->last_result[$num_rows] = $row;
227227
$num_rows++;
228228
}
229229

230230
@\pg_free_result($this->result);
231231
}
232232
// Log number of rows the query returned
233-
$this->numRows = $num_rows;
233+
$this->num_rows = $num_rows;
234234

235235
// Return number of rows selected
236-
$this->return_val = $this->numRows;
236+
$this->return_val = $this->num_rows;
237237
}
238238
}
239239

@@ -276,7 +276,7 @@ public function query(string $query, bool $use_prepare = false)
276276
$this->log_query("\$db->query(\"$query\")");
277277

278278
// Keep track of the last query for debug..
279-
$this->lastQuery = $query;
279+
$this->last_query = $query;
280280

281281
// Count how many queries there have been
282282
$this->count(true, true);
@@ -320,7 +320,7 @@ public function query(string $query, bool $use_prepare = false)
320320
$this->store_cache($query, $this->is_insert);
321321

322322
// If debug ALL queries
323-
$this->trace || $this->debugAll ? $this->debug() : null;
323+
$this->trace || $this->debug_all ? $this->debug() : null;
324324

325325
return $this->return_val;
326326
} // query

0 commit comments

Comments
 (0)