Skip to content

Commit 0b5b175

Browse files
4.13.1
1 parent f735648 commit 0b5b175

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

lib/PdoOne.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
* @package eftec
3131
* @author Jorge Castro Castillo
3232
* @copyright (c) Jorge Castro C. Dual Licence: MIT and Commercial License https://github.com/EFTEC/PdoOne
33-
* @version 4.13
33+
* @version 4.13.1
3434
*/
3535
class PdoOne
3636
{
37-
public const VERSION = '4.13';
37+
public const VERSION = '4.13.1';
3838
/** @var int We need this value because null and false could be a valid value. */
3939
public const NULL = PHP_INT_MAX;
4040
/** @var string Prefix of the related columns. It is used for ORM */
@@ -209,8 +209,9 @@ class PdoOne
209209
* for sequence. Form 0 to 1023
210210
* @param string $tableKV (optional), the name of the table key-value
211211
* @param string $instanceName (optional, default "0"), the name of the instance
212+
* @param string|null $prefix The prefix of the associative column. By default is "_". Null keeps the value
213+
* @param string|null $postfix The postfix of the associative column. Null keeps the value.
212214
* @see PdoOne::connect()
213-
* @noinspection ClassConstantCanBeUsedInspection
214215
*/
215216
public function __construct(
216217
$databaseType,
@@ -223,8 +224,8 @@ public function __construct(
223224
int $nodeId = 1,
224225
string $tableKV = '',
225226
string $instanceName = "0",
226-
string $prefix = '_',
227-
string $postfix = ''
227+
?string $prefix = null,
228+
?string $postfix = null
228229
)
229230
{
230231
if(is_array($databaseType)) {
@@ -239,12 +240,14 @@ public function __construct(
239240
$nodeId=$cp['nodeId']??1;
240241
$tableKV=$cp['tableKV']??'';
241242
$instanceName=$cp['$instanceName']??'0';
242-
self::$prefixBase = $cp['prefix']??'_';
243-
self::$postfixBase = $cp['postfix']??'';
243+
244+
self::$prefixBase = $cp['prefix']??self::$prefixBase;
245+
self::$postfixBase = $cp['postfix']??self::$postfixBase;
244246

245247
}
246248
$this->construct($databaseType, $server, $user, $pwd, $db, $logFile,
247249
$charset, $nodeId, $tableKV,$prefix,$postfix);
250+
/** @noinspection ClassConstantCanBeUsedInspection */
248251
if (class_exists('eftec\MessageContainer')) {
249252
// autowire MessageContainer if the method exists.
250253
$this->messageContainer = MessageContainer::instance();
@@ -350,8 +353,8 @@ protected function construct(
350353
$charset = null,
351354
$nodeId = 1,
352355
$tableKV = '',
353-
$prefix = '_',
354-
$postfix = ''
356+
$prefix = null,
357+
$postfix = null
355358
): void
356359
{
357360
$this->databaseType = $databaseType;
@@ -379,8 +382,8 @@ protected function construct(
379382
default:
380383
throw new RuntimeException('no database type selected');
381384
}
382-
self::$prefixBase = $prefix??'_';
383-
self::$postfixBase = $postfix??'';
385+
self::$prefixBase = $prefix??self::$prefixBase;
386+
self::$postfixBase = $postfix??self::$postfixBase;
384387
$charset = $this->service->construct($charset, []);
385388
$this->server = $server;
386389
$this->user = $user;

lib/PdoOneCli.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ public function pdoGetConfigArray():array
337337
}
338338
public function pdoSetConfigArray(array $array): void
339339
{
340+
$lf=$array['logFile']??'false';
340341
$backup=$this->cli->getValue('logFile'); //yes|no
341-
$this->cli->setParam('logFile',$array['logFile']?'yes':'no',false,true); //true|false
342+
$this->cli->setParam('logFile',$lf?'yes':'no',false,true); //true|false
342343
$this->cli->setParamUsingArray($array,['databaseType','server','user','pwd','database','logFile','charset','nodeId','tableKV','prefix','postfix']);
343344
$this->cli->setParam('logFile',$backup);//yes|no
344345
}
@@ -350,6 +351,7 @@ public function doReadConfig(): void
350351
$this->cli->showCheck('OK', 'green', 'file read correctly');
351352
$this->cli->setVariable('connect', '<green>ok</green>');
352353
$this->pdoSetConfigArray($r[1]);
354+
PdoOne::$prefixBase=$this->cli->getValue('prefix');
353355
} else {
354356
$this->cli->showCheck('ERROR', 'red', 'unable to read file ' . $this->cli->getValue('fileconnect') . ", cause " . $r[1]);
355357
}

0 commit comments

Comments
 (0)