Skip to content

Commit

Permalink
Remove method showCreateTable
Browse files Browse the repository at this point in the history
  • Loading branch information
kamshory committed Aug 3, 2024
1 parent 05ce9b5 commit f833384
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
40 changes: 18 additions & 22 deletions src/Database/PicoDatabasePersistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -2505,9 +2505,7 @@ public function findBy($propertyName, $propertyValue, $pageable = null, $sortabl
$info = $this->getTableInfo();
$data = null;
$result = array();

$sqlQuery = $this->findByQuery($propertyName, $propertyValue, $pageable, $sortable, $info, $subqueryMap);

try
{
$stmt = $this->database->executeQuery($sqlQuery);
Expand Down Expand Up @@ -2561,21 +2559,18 @@ public function countAll($specification = null, $pageable = null, $sortable = nu
{
$info = $this->getTableInfo();
$primaryKeys = array_values($info->getPrimaryKeys());
$agg = "*";
if(is_array($primaryKeys) && isset($primaryKeys[0][self::KEY_NAME]))
{
// it will be faster than asterisk
$agg = $primaryKeys[0][self::KEY_NAME];
}
else
{
$agg = "*";
}
$queryBuilder = new PicoDatabaseQueryBuilder($this->database);
$sqlQuery = $queryBuilder
->newQuery()
->select($this->getAllColumns($info))
->from($info->getTableName());
->from($info->getTableName())
;
if($specification != null && $specification instanceof PicoSpecification)
{
if($this->isRequireJoin($specification, $pageable, $sortable, $info))
Expand All @@ -2590,7 +2585,7 @@ public function countAll($specification = null, $pageable = null, $sortable = nu
->newQuery()
->select($agg)
->from($info->getTableName())
;
;
}
try
{
Expand All @@ -2615,15 +2610,12 @@ public function countBy($propertyName, $propertyValue)
{
$info = $this->getTableInfo();
$primaryKeys = array_values($info->getPrimaryKeys());
$agg = "*";
if(is_array($primaryKeys) && isset($primaryKeys[0][self::KEY_NAME]))
{
// it will be faster than asterisk
$agg = $primaryKeys[0][self::KEY_NAME];
}
else
{
$agg = "*";
}
$where = $this->createWhereFromArgs($info, $propertyName, $propertyValue);
if(!$this->isValidFilter($where))
{
Expand All @@ -2634,7 +2626,8 @@ public function countBy($propertyName, $propertyValue)
->newQuery()
->select($agg)
->from($info->getTableName())
->where($where);
->where($where)
;
try
{
$stmt = $this->database->executeQuery($sqlQuery);
Expand Down Expand Up @@ -2674,7 +2667,8 @@ public function deleteBy($propertyName, $propertyValue)
->newQuery()
->delete()
->from($info->getTableName())
->where($where);
->where($where)
;
try
{
$stmt = $this->database->executeQuery($sqlQuery);
Expand Down Expand Up @@ -2718,8 +2712,7 @@ public function findOneBy($propertyName, $propertyValue, $sortable = null)
->from($info->getTableName())
->where($where);
$sqlQuery = $this->setSortable($sqlQuery, null, $sortable, $info);
$sqlQuery->limit(1)
->offset(0);
$sqlQuery->limit(1)->offset(0);
try
{
$stmt = $this->database->executeQuery($sqlQuery);
Expand Down Expand Up @@ -2763,7 +2756,8 @@ public function deleteOneBy($propertyName, $propertyValue)
->newQuery()
->delete()
->from($info->getTableName())
->where($where);
->where($where)
;
try
{
$stmt = $this->database->executeQuery($sqlQuery);
Expand Down Expand Up @@ -3375,7 +3369,8 @@ private function _selectQuery($info = null, $queryBuilder = null, $where = null)
->newQuery()
->select($this->getAllColumns($info))
->from($info->getTableName())
->where($where);
->where($where)
;
}

/**
Expand Down Expand Up @@ -3457,7 +3452,8 @@ private function _updateQuery($info = null, $queryBuilder = null, $where = null)
->newQuery()
->update($info->getTableName())
->set($set)
->where($where);
->where($where)
;
}

/**
Expand Down Expand Up @@ -3533,7 +3529,8 @@ private function _deleteQuery($info = null, $queryBuilder = null, $where = null)
->newQuery()
->delete()
->from($info->getTableName())
->where($where);
->where($where)
;
}

/**
Expand Down Expand Up @@ -3562,7 +3559,6 @@ public function whereWithSpecification($specification)
{
// Do nothing
}

return $persist;
}

Expand Down
15 changes: 0 additions & 15 deletions src/MagicObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use MagicObject\Database\PicoDatabasePersistence;
use MagicObject\Database\PicoDatabasePersistenceExtended;
use MagicObject\Database\PicoDatabaseQueryBuilder;
use MagicObject\Database\PicoDatabaseStructure;
use MagicObject\Database\PicoPageable;
use MagicObject\Database\PicoPageData;
use MagicObject\Database\PicoSortable;
Expand Down Expand Up @@ -721,19 +720,6 @@ public function where($specification)
throw new NoDatabaseConnectionException(self::MESSAGE_NO_DATABASE_CONNECTION);
}
}

/**
* Scho create table
*
* @param string $databaseType
* @param string $tableName
* @return string
*/
public function showCreateTable($databaseType, $tableName = null)
{
$structure = new PicoDatabaseStructure($this);
return $structure->showCreateTable($databaseType, $tableName);
}

/**
* Modify null properties
Expand Down Expand Up @@ -1198,7 +1184,6 @@ private function countData($persist, $specification, $pageable, $sortable, $find
{
$match = $persist->countAll($specification, $pageable, $sortable);
}

return $match;
}

Expand Down

0 comments on commit f833384

Please sign in to comment.