Skip to content

Commit

Permalink
Merge pull request #51 from Planetbiru/feature/2.14.1
Browse files Browse the repository at this point in the history
Feature/2.14.1
  • Loading branch information
kamshory authored Jan 30, 2025
2 parents 8e65476 + 4b4cd92 commit d472fca
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 35 deletions.
Binary file added doc.html
Binary file not shown.
2 changes: 2 additions & 0 deletions manual/includes/_upload-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ $files = new PicoUploadFile();
$file1 = $files->get('myupload');
// or alternatively
// $file1 = $files->myupload;
// or
// $file1 = $files->getMyupload();

$targetDir = __DIR__;

Expand Down
2 changes: 2 additions & 0 deletions manual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10850,6 +10850,8 @@ <h3>PHP Backend Handling</h3>
$file1 = $files-&gt;get('myupload');
// or alternatively
// $file1 = $files-&gt;myupload;
// or
// $file1 = $files-&gt;getMyupload();

$targetDir = __DIR__;

Expand Down
51 changes: 17 additions & 34 deletions src/Database/PicoDatabasePersistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
use DateTime;
use Exception;
use MagicObject\Exceptions\ClassNotFoundException;
use PDO;
use PDOException;
use PDOStatement;
use MagicObject\Exceptions\EmptyResultException;
use MagicObject\Exceptions\EntityException;
use MagicObject\Exceptions\InvalidAnnotationException;
Expand All @@ -22,6 +19,9 @@
use MagicObject\Util\ClassUtil\PicoAnnotationParser;
use MagicObject\Util\ClassUtil\PicoEmptyParameter;
use MagicObject\Util\Database\PicoDatabaseUtil;
use PDO;
use PDOException;
use PDOStatement;
use ReflectionProperty;

/**
Expand Down Expand Up @@ -78,6 +78,8 @@ class PicoDatabasePersistence // NOSONAR

const COMMA = ", ";
const COMMA_RETURN = ", \r\n";
const INLINE_TRIM = " \r\n\t ";
const ALWAYS_TRUE = "(1=1)";

/**
* Database connection
Expand Down Expand Up @@ -355,7 +357,7 @@ private function addColumnType($columns, $reflexProp, $prop, $parameters)
{
if(strcasecmp($param, self::ANNOTATION_VAR) == 0 && isset($columns[$prop->name]))
{
$type = explode(' ', trim($val, " \r\n\t "))[0];
$type = explode(' ', trim($val, self::INLINE_TRIM))[0];
$columns[$prop->name][self::KEY_PROPERTY_TYPE] = $type;
}
if(strcasecmp($param, self::SQL_DATE_TIME_FORMAT) == 0)
Expand Down Expand Up @@ -409,7 +411,7 @@ private function addJoinColumnType($joinColumns, $prop, $parameters)
{
if(strcasecmp($param, self::ANNOTATION_VAR) == 0 && isset($joinColumns[$prop->name]))
{
$type = explode(' ', trim($val, " \r\n\t "))[0];
$type = explode(' ', trim($val, self::INLINE_TRIM))[0];
$joinColumns[$prop->name][self::KEY_PROPERTY_TYPE] = $type;
$joinColumns[$prop->name][self::KEY_ENTITY_OBJECT] = true;
}
Expand Down Expand Up @@ -563,36 +565,28 @@ public function getTableInfo()
$parameters = $reflexProp->getParameters();

// get column name of each parameters
$columns = $this->addColumnName($columns, $reflexProp, $prop, $parameters);

$columns = $this->addColumnName($columns, $reflexProp, $prop, $parameters);

// set column type
$columns = $this->addColumnType($columns, $reflexProp, $prop, $parameters);

$columns = $this->addColumnType($columns, $reflexProp, $prop, $parameters);

// get join column name of each parameters
$joinColumns = $this->addJoinColumnName($joinColumns, $reflexProp, $prop, $parameters);

$joinColumns = $this->addJoinColumnName($joinColumns, $reflexProp, $prop, $parameters);

// set join column type
$joinColumns = $this->addJoinColumnType($joinColumns, $prop, $parameters);

$joinColumns = $this->addJoinColumnType($joinColumns, $prop, $parameters);

// list primary key
$primaryKeys = $this->addPrimaryKey($primaryKeys, $columns, $prop, $parameters);

$primaryKeys = $this->addPrimaryKey($primaryKeys, $columns, $prop, $parameters);

// list autogenerated column
$autoIncrementKeys = $this->addAutogenerated($autoIncrementKeys, $columns, $reflexClass, $prop, $parameters);

$autoIncrementKeys = $this->addAutogenerated($autoIncrementKeys, $columns, $reflexClass, $prop, $parameters);

// define default column value
$defaultValue = $this->addDefaultValue($defaultValue, $columns, $reflexClass, $prop, $parameters);

$defaultValue = $this->addDefaultValue($defaultValue, $columns, $reflexClass, $prop, $parameters);

// list not null column
$notNullColumns = $this->addNotNull($notNullColumns, $columns, $prop, $parameters);

$notNullColumns = $this->addNotNull($notNullColumns, $columns, $prop, $parameters);
}
// bring it together
$this->tableInfoProp = new PicoTableInfo($picoTableName, $columns, $joinColumns, $primaryKeys, $autoIncrementKeys, $defaultValue, $notNullColumns, $noCache, $package);
Expand Down Expand Up @@ -1501,7 +1495,7 @@ protected function createWhereFromSpecification($sqlQuery, $specification, $info
{
$masterColumnMaps = $this->getColumnMap($info);
$arr = array();
$arr[] = "(1=1)";
$arr[] = self::ALWAYS_TRUE;
if($specification != null && !$specification->isEmpty())
{
$specifications = $specification->getSpecifications();
Expand All @@ -1511,7 +1505,7 @@ protected function createWhereFromSpecification($sqlQuery, $specification, $info
}
}
$ret = $this->joinStringArray($arr, self::MAX_LINE_LENGTH);
return $this->trimWhere($ret);
return PicoDatabaseUtil::trimWhere($ret);
}

/**
Expand Down Expand Up @@ -1688,17 +1682,6 @@ private function formatColumn($column, $format)
}
return sprintf($format, $column);
}

/**
* Trim unnecessary parts from WHERE clause
*
* @param string $where WHERE clause string
* @return string Trimmed WHERE clause
*/
private function trimWhere($where)
{
return PicoDatabaseUtil::trimWhere($where);
}

/**
* Create ORDER BY clause
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Database/PicoDatabaseUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static function escapeSQL($value)
return addslashes($value);
}

/**
/**
* Trim a WHERE clause by removing unnecessary characters.
*
* This method cleans up a raw WHERE clause by trimming whitespace
Expand Down
2 changes: 2 additions & 0 deletions tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -12305,6 +12305,8 @@ $files = new PicoUploadFile();
$file1 = $files->get('myupload');
// or alternatively
// $file1 = $files->myupload;
// or
// $file1 = $files->getMyupload();

$targetDir = __DIR__;

Expand Down

0 comments on commit d472fca

Please sign in to comment.