@@ -131,7 +131,7 @@ public function __construct(string $host = '', string $user = '', string $pass =
131
131
$ this ->connected = false ;
132
132
$ this ->ok = false ;
133
133
$ this ->error = $ langs ->trans ('ErrorWrongHostParameter ' );
134
- if (empty (PM_DISABLE_SYSLOG )) {
134
+ if (empty (DISABLE_SYSLOG )) {
135
135
pm_syslog (get_class ($ this ) . ': Connect error, wrong host parameters ' , PM_LOG_ERR );
136
136
}
137
137
@@ -149,7 +149,7 @@ public function __construct(string $host = '', string $user = '', string $pass =
149
149
$ this ->error = $ this ->db ->errorCode ();
150
150
}
151
151
152
- if (empty (PM_DISABLE_SYSLOG )) {
152
+ if (empty (DISABLE_SYSLOG )) {
153
153
pm_syslog (get_class ($ this ) . ': Connect error: ' . $ this ->error , PM_LOG_ERR );
154
154
}
155
155
@@ -179,7 +179,7 @@ public function __construct(string $host = '', string $user = '', string $pass =
179
179
} elseif (isset ($ this ->db ) && $ this ->db ->errorCode ()) {
180
180
$ this ->error = $ this ->db ->errorCode ();
181
181
}
182
- if (empty (PM_DISABLE_SYSLOG )) {
182
+ if (empty (DISABLE_SYSLOG )) {
183
183
pm_syslog (get_class ($ this ) . ': Select_db error ' . $ this ->error , PM_LOG_ERR );
184
184
}
185
185
@@ -209,7 +209,7 @@ public function connect(string $host, string $login, string $passwd, string $nam
209
209
return $ this ->db ;
210
210
} catch (PDOException $ e ) {
211
211
$ this ->error = 'Connection failed: ' . $ e ->getMessage ();
212
- if (empty (PM_DISABLE_SYSLOG )) {
212
+ if (empty (DISABLE_SYSLOG )) {
213
213
pm_syslog ('ERROR: ' . $ this ->error . ' for method ' . __METHOD__ . ' in class ' . get_class ($ this ), PM_LOG_ERR );
214
214
}
215
215
}
@@ -232,7 +232,7 @@ public function connect(string $host, string $login, string $passwd, string $nam
232
232
public function selectDb (string $ host , string $ login , string $ passwd , string $ name , string $ charset , string $ collation , int $ port = 0 )
233
233
{
234
234
235
- if (empty (PM_DISABLE_SYSLOG )) {
235
+ if (empty (DISABLE_SYSLOG )) {
236
236
pm_syslog (get_class ($ this ) . '::select_db database= ' . $ name , PM_LOG_INFO );
237
237
}
238
238
@@ -243,7 +243,7 @@ public function selectDb(string $host, string $login, string $passwd, string $na
243
243
return $ this ->db ;
244
244
} catch (PDOException $ e ) {
245
245
$ this ->error = 'Connection failed: ' . $ e ->getMessage ();
246
- if (empty (PM_DISABLE_SYSLOG )) {
246
+ if (empty (DISABLE_SYSLOG )) {
247
247
pm_syslog ('ERROR: ' . $ this ->error . ' for method construct in class ' . get_class ($ this ), PM_LOG_ERR );
248
248
}
249
249
@@ -274,7 +274,7 @@ public function create(array $array_of_fields, string $table_element)
274
274
}
275
275
$ sql = preg_replace ('/,\s*$/ ' , '' , $ sql );
276
276
$ sql .= ') ' ;
277
- if (empty (PM_DISABLE_SYSLOG )) {
277
+ if (empty (DISABLE_SYSLOG )) {
278
278
pm_syslog ('query:: sql = ' . $ sql , PM_LOG_DEBUG );
279
279
}
280
280
$ query = $ this ->db ->prepare ($ sql );
@@ -288,16 +288,17 @@ public function create(array $array_of_fields, string $table_element)
288
288
289
289
try {
290
290
$ result = $ query ->execute ();
291
+ $ last_id = $ this ->db ->lastInsertId ();
291
292
if ($ result ) {
292
- if (empty (PM_DISABLE_SYSLOG )) {
293
+ if (empty (DISABLE_SYSLOG )) {
293
294
pm_syslog (get_class ($ this ) . ':: record with id= ' . $ this ->db ->lastInsertId () . ' inserted into ' . $ table_element , PM_LOG_INFO );
294
295
}
295
296
$ this ->db ->commit ();
296
297
297
- return 1 ;
298
+ return $ last_id ;
298
299
} else {
299
300
$ this ->db ->rollBack ();
300
- if (empty (PM_DISABLE_SYSLOG )) {
301
+ if (empty (DISABLE_SYSLOG )) {
301
302
pm_syslog (get_class ($ this ) . ':: ' . __METHOD__ . ' error: ' . $ this ->error , PM_LOG_ERR );
302
303
}
303
304
@@ -306,7 +307,7 @@ public function create(array $array_of_fields, string $table_element)
306
307
} catch (PDOException $ e ) {
307
308
$ this ->db ->rollBack ();
308
309
$ this ->error = $ e ->getMessage ();
309
- if (empty (PM_DISABLE_SYSLOG )) {
310
+ if (empty (DISABLE_SYSLOG )) {
310
311
pm_syslog (get_class ($ this ) . ':: ' . __METHOD__ . ' error: ' . $ this ->error , PM_LOG_ERR );
311
312
}
312
313
@@ -333,7 +334,7 @@ public function update(array $filter, string $table_element, int $record_id)
333
334
}
334
335
$ sql = preg_replace ('/,\s*$/ ' , '' , $ sql );
335
336
$ sql .= ' WHERE rowid = :id ' ;
336
- if (empty (PM_DISABLE_SYSLOG )) {
337
+ if (empty (DISABLE_SYSLOG )) {
337
338
pm_syslog ('query:: sql = ' . $ sql , PM_LOG_DEBUG );
338
339
}
339
340
$ query = $ this ->db ->prepare ($ sql );
@@ -349,7 +350,7 @@ public function update(array $filter, string $table_element, int $record_id)
349
350
350
351
try {
351
352
$ query ->execute ();
352
- if (empty (PM_DISABLE_SYSLOG )) {
353
+ if (empty (DISABLE_SYSLOG )) {
353
354
pm_syslog (get_class ($ this ) . ':: record with id= ' . $ this ->db ->lastInsertId () . ' from ' . $ table_element . 'was updated ' , PM_LOG_INFO );
354
355
}
355
356
$ this ->db ->commit ();
@@ -358,7 +359,7 @@ public function update(array $filter, string $table_element, int $record_id)
358
359
} catch (PDOException $ e ) {
359
360
$ this ->db ->rollBack ();
360
361
$ this ->error = $ e ->getMessage ();
361
- if (empty (PM_DISABLE_SYSLOG )) {
362
+ if (empty (DISABLE_SYSLOG )) {
362
363
pm_syslog (get_class ($ this ) . ':: ' . __METHOD__ . ' error: ' . $ this ->error , PM_LOG_ERR );
363
364
}
364
365
@@ -379,7 +380,7 @@ public function delete(string $table_element, int $record_id)
379
380
{
380
381
381
382
$ sql = 'DELETE FROM ' . PM_MAIN_DB_PREFIX . $ table_element . ' WHERE rowid = :id ' ;
382
- if (empty (PM_DISABLE_SYSLOG )) {
383
+ if (empty (DISABLE_SYSLOG )) {
383
384
pm_syslog ('query:: sql = ' . $ sql , PM_LOG_DEBUG );
384
385
}
385
386
$ query = $ this ->db ->prepare ($ sql );
@@ -390,7 +391,7 @@ public function delete(string $table_element, int $record_id)
390
391
391
392
try {
392
393
$ query ->execute ();
393
- if (empty (PM_DISABLE_SYSLOG )) {
394
+ if (empty (DISABLE_SYSLOG )) {
394
395
pm_syslog (get_class ($ this ) . ':: record with id= ' . $ this ->db ->lastInsertId () . ' from ' . $ table_element . 'was deleted ' , PM_LOG_INFO );
395
396
}
396
397
$ this ->db ->commit ();
@@ -399,7 +400,7 @@ public function delete(string $table_element, int $record_id)
399
400
} catch (PDOException $ e ) {
400
401
$ this ->db ->rollBack ();
401
402
$ this ->error = $ e ->getMessage ();
402
- if (empty (PM_DISABLE_SYSLOG )) {
403
+ if (empty (DISABLE_SYSLOG )) {
403
404
pm_syslog (get_class ($ this ) . ':: ' . __METHOD__ . ' error: ' . $ this ->error , PM_LOG_ERR );
404
405
}
405
406
@@ -486,7 +487,7 @@ public function fetchAll(array $array_of_fields, string $table_element, $filter
486
487
$ sql .= ' LIMIT ' . $ limit . ' OFFSET ' . $ offset ;
487
488
}
488
489
489
- if (empty (PM_DISABLE_SYSLOG )) {
490
+ if (empty (DISABLE_SYSLOG )) {
490
491
pm_syslog ('query:: sql = ' . $ sql , PM_LOG_DEBUG );
491
492
}
492
493
$ query = $ this ->db ->prepare ($ sql );
@@ -517,7 +518,7 @@ public function fetchAll(array $array_of_fields, string $table_element, $filter
517
518
} catch (PDOException $ e ) {
518
519
$ this ->db ->rollBack ();
519
520
$ this ->error = $ e ->getMessage ();
520
- if (empty (PM_DISABLE_SYSLOG )) {
521
+ if (empty (DISABLE_SYSLOG )) {
521
522
pm_syslog (get_class ($ this ) . ':: ' . __METHOD__ . ' error: ' . $ this ->error , PM_LOG_ERR );
522
523
}
523
524
@@ -598,7 +599,7 @@ public function fetch($id = '', array $array_of_fields, string $table_element, $
598
599
$ sql .= ' LIMIT ' . $ limit . ' OFFSET ' . $ offset ;
599
600
}
600
601
601
- if (empty (PM_DISABLE_SYSLOG )) {
602
+ if (empty (DISABLE_SYSLOG )) {
602
603
pm_syslog ('query:: sql = ' . $ sql , PM_LOG_DEBUG );
603
604
}
604
605
$ query = $ this ->db ->prepare ($ sql );
@@ -631,7 +632,7 @@ public function fetch($id = '', array $array_of_fields, string $table_element, $
631
632
} catch (PDOException $ e ) {
632
633
$ this ->db ->rollBack ();
633
634
$ this ->error = $ e ->getMessage ();
634
- if (empty (PM_DISABLE_SYSLOG )) {
635
+ if (empty (DISABLE_SYSLOG )) {
635
636
pm_syslog (get_class ($ this ) . ':: ' . __METHOD__ . ' error: ' . $ this ->error , PM_LOG_ERR );
636
637
}
637
638
0 commit comments