Skip to content

Commit

Permalink
* 2.11.1 see README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecc committed Apr 17, 2021
1 parent 7a735e4 commit 16d7308
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1953,10 +1953,15 @@ In a nutshell:
* Every minor version means that it adds a new functionality i.e. 1.5 -> 1.6 (new methods)
* Every decimal version means that it patches/fixes/refactoring a previous functionality i.e. 1.5.0 -> 1.5.1 (fix)


* 2.11.1 2021-04-17
* [fix] Mysql extension now knows the type int24 (plus other types of variables).
* [fix] Regresion, some removed { } caused a bug when they are followed by []
* [code]
* 2.11 2021-04-17
* [code] Lots of cleanups. Removed unneeding { }. Merged common code in branches.
* 2.10.3 2021-04-14
* [fix] BasePdoOne fixed method getRecursive(), it generated a new query and now it reuses a query (if any).
* [fix] BasePdoOne fixed method getRecursive(), it generated a new query, and now it reuses a query (if any).
* It also returns the query
* 2.10.2 2021-04-06
* Fixed
Expand Down
40 changes: 19 additions & 21 deletions lib/PdoOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@
* @package eftec
* @author Jorge Castro Castillo
* @copyright (c) Jorge Castro C. MIT License https://github.com/EFTEC/PdoOne
* @version 2.11
* @version 2.11.1
*/
class PdoOne
{
const VERSION = '2.11';
const VERSION = '2.11.1';
/** @var int We need this value because null and false could be a valid value. */
const NULL = PHP_INT_MAX;
protected $phpstart="<?php\n";
/** @var string Prefix of the tables */
public static $prefixBase = '_';
/** @var string|null Static date (when the date is empty) */
public static $dateEpoch = '2000-01-01 00:00:00.00000';
public static $dateEpoch = '2000-01-01 00:00:00.00000'; // we don't need to set the epoch to 1970.
/**
* Text date format
*
Expand Down Expand Up @@ -2353,8 +2354,7 @@ public function generateCodeClass(
$columnRemove = []
)
{
$r = <<<'eot'
<?php
$r = $this->phpstart.<<<'eot'
/** @noinspection PhpUnusedParameterInspection
* @noinspection NullCoalescingOperatorCanBeUsedInspection
* @noinspection PhpPureAttributeCanBeAddedInspection
Expand Down Expand Up @@ -2728,7 +2728,10 @@ public static function factoryNull($values=null) {
$modelUse = false;
}

$baseClass = ($baseClass === null) ? end($lastns) : $baseClass;
if ($baseClass === null) {
$tmp3 = end($lastns);
$baseClass=$tmp3===false?'':$tmp3;
}

$fa = func_get_args();
foreach ($fa as $f => $k) {
Expand Down Expand Up @@ -3511,8 +3514,7 @@ public function setUseInternalCache($useInternalCache = true)

public function generateBaseClass($baseClassName, $namespace, $classes, $modelUse = false)
{
$r = <<<'eot'
<?php
$r = $this->phpstart.<<<'eot'
/** @noinspection PhpMissingParamTypeInspection */
/** @noinspection PhpMissingReturnTypeInspection */
/** @noinspection PhpMissingFieldTypeInspection */
Expand Down Expand Up @@ -3617,6 +3619,7 @@ protected function tabletoClass($tableName) {
*
* @return string|string[]
* @throws Exception
* @noinspection PhpUnnecessaryCurlyVarSyntaxInspection
*/
public function generateAbstractModelClass(
$tableName,
Expand All @@ -3631,8 +3634,7 @@ public function generateAbstractModelClass(
$columnRemove = []
)
{
$r = <<<'eot'
<?php
$r = $this->phpstart.<<<'eot'
/** @noinspection PhpIncompatibleReturnTypeInspection
* @noinspection ReturnTypeCanBeDeclaredInspection
* @noinspection DuplicatedCode
Expand Down Expand Up @@ -3905,15 +3907,15 @@ public static function fromArrayMultiple($array) {
break;
case 'MANYTOMANY':
$class = $classRelations[$field['reftable']];
$field2s[] = "\t/** @var $class[] \$$varn manytomany */
$field2s[] = "\t/** @var {$class}[] \$$varn manytomany */
public \$$varn;";
$field2sb[] = "\t\t\$obj->$varn=isset(\$array['$varn']) ?
\$obj->$varn=$class::fromArrayMultiple(\$array['$varn'])
: null; // manytomany";
break;
case 'ONETOMANY':
$class = $classRelations[$field['reftable']];
$field2s[] = "\t/** @var $class[] \$$varn onetomany */
$field2s[] = "\t/** @var {$class}[] \$$varn onetomany */
public \$$varn;";
$field2sb[] = "\t\t\$obj->$varn=isset(\$array['$varn']) ?
\$obj->$varn=$class::fromArrayMultiple(\$array['$varn'])
Expand Down Expand Up @@ -4016,6 +4018,7 @@ public static function fromArrayMultiple($array) {
*
* @return string|string[]
* @throws Exception
* @noinspection PhpUnnecessaryCurlyVarSyntaxInspection
*/
public function generateModelClass(
$tableName,
Expand All @@ -4028,8 +4031,7 @@ public function generateModelClass(
$baseClass = null
)
{
$r = <<<'eot'
<?php
$r = $this->phpstart.<<<'eot'
/** @noinspection PhpIncompatibleReturnTypeInspection
* @noinspection ReturnTypeCanBeDeclaredInspection
* @noinspection DuplicatedCode
Expand Down Expand Up @@ -4230,15 +4232,15 @@ class {classname} extends Abstract{classname}
break;
case 'MANYTOMANY':
$class = $classRelations[$field['reftable']];
$field2s[] = "\t/** @var $class[] \$$varn manytomany */
$field2s[] = "\t/** @var {$class}[] \$$varn manytomany */
public \$$varn;";
$field2sb[] = "\t\t\$obj->$varn=isset(\$array['$varn']) ?
\$obj->$varn=$class::fromArrayMultiple(\$array['$varn'])
: null; // manytomany";
break;
case 'ONETOMANY':
$class = $classRelations[$field['reftable']];
$field2s[] = "\t/** @var $class[] \$$varn onetomany */
$field2s[] = "\t/** @var {$class}[] \$$varn onetomany */
public \$$varn;";
$field2sb[] = "\t\t\$obj->$varn=isset(\$array['$varn']) ?
\$obj->$varn=$class::fromArrayMultiple(\$array['$varn'])
Expand All @@ -4260,9 +4262,6 @@ class {classname} extends Abstract{classname}

$r = str_replace(['{fields}', '{fieldsrel}', '{fieldsfa}', '{fieldsrelfa}'],
[$fieldsArr, $fields2Arr, $fieldsbArr, $fields2Arrb], $r);
// return $r;
// die(1);

if (@count($this->codeClassConversion) > 0) {
// we forced the conversion but only if it is not specified explicit
foreach ($gdf as $k => $colDef) {
Expand Down Expand Up @@ -4329,8 +4328,7 @@ public function generateCodeClassRepo(
$modelfullClass = ''
)
{
$r = <<<'eot'
<?php
$r = $this->phpstart.<<<'eot'
/** @noinspection AccessModifierPresentedInspection
* @noinspection PhpUnusedAliasInspection
* @noinspection UnknownInspectionInspection
Expand Down
16 changes: 10 additions & 6 deletions lib/ext/PdoOne_Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function construct($charset)
PdoOne::$dateTimeMicroFormat = 'Y-m-d H:i:s.u';
PdoOne::$isoDateInput = 'Y-m-d';
PdoOne::$isoDateInputTime = 'Y-m-d H:i:s';
PdoOne::$isoDateInputTimeMs = 'Y-m-d H:i:s.u';
PdoOne::$isoDateInputTimeMs = 'Y-m-d H:i:s.u';
$this->parent->isOpen = false;

return $charset;
Expand All @@ -59,7 +59,7 @@ public function connect($cs, $alterSession=false)
$this->parent->user = '';
$this->parent->pwd = '';
$this->parent->conn1->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

}
public function callProcedure($procName, &$arguments=[], $outputColumns=[]) {
$keys=array_keys($arguments);
Expand Down Expand Up @@ -97,7 +97,7 @@ public function callProcedure($procName, &$arguments=[], $outputColumns=[]) {
}
$stmt=null;
}

public function truncate($tableName,$extra,$force) {
if(!$force) {
$sql = 'truncate table ' . $this->parent->addDelimiter($tableName) . " $extra";
Expand Down Expand Up @@ -208,6 +208,9 @@ public function typeDict($row, $default = true)
switch ($type) {
case 'VAR_STRING':
case 'BLOB':
case 'TINY_BLOB':
case 'MEDIUM_BLOB':
case 'LONG_BLOB':
case 'STRING':
case 'GEOMETRY':
case 'TIMESTAMP':
Expand All @@ -219,6 +222,7 @@ public function typeDict($row, $default = true)
case 'LONG':
case 'LONGLONG':
case 'SHORT':
case 'INT24':
case 'TINY':
case 'YEAR':
return ($default) ? '0' : 'int';
Expand Down Expand Up @@ -319,9 +323,9 @@ public function createSequence($tableSequence = null, $method = 'snowflake')
'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT',
'stub' => "char(1) NOT NULL DEFAULT ''",
], [
'id' => 'PRIMARY KEY',
'stub' => 'UNIQUE KEY'
], '', 'ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8');
'id' => 'PRIMARY KEY',
'stub' => 'UNIQUE KEY'
], '', 'ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8');
if (!$ok) {
$this->parent->throwError("Unable to create table $tableSequence", '');
return '';
Expand Down

0 comments on commit 16d7308

Please sign in to comment.