diff --git a/src/Database/PicoDatabasePersistence.php b/src/Database/PicoDatabasePersistence.php index 4e9a85d..aba09a0 100644 --- a/src/Database/PicoDatabasePersistence.php +++ b/src/Database/PicoDatabasePersistence.php @@ -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); @@ -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)) @@ -2590,7 +2585,7 @@ public function countAll($specification = null, $pageable = null, $sortable = nu ->newQuery() ->select($agg) ->from($info->getTableName()) - ; + ; } try { @@ -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)) { @@ -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); @@ -2674,7 +2667,8 @@ public function deleteBy($propertyName, $propertyValue) ->newQuery() ->delete() ->from($info->getTableName()) - ->where($where); + ->where($where) + ; try { $stmt = $this->database->executeQuery($sqlQuery); @@ -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); @@ -2763,7 +2756,8 @@ public function deleteOneBy($propertyName, $propertyValue) ->newQuery() ->delete() ->from($info->getTableName()) - ->where($where); + ->where($where) + ; try { $stmt = $this->database->executeQuery($sqlQuery); @@ -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) + ; } /** @@ -3457,7 +3452,8 @@ private function _updateQuery($info = null, $queryBuilder = null, $where = null) ->newQuery() ->update($info->getTableName()) ->set($set) - ->where($where); + ->where($where) + ; } /** @@ -3533,7 +3529,8 @@ private function _deleteQuery($info = null, $queryBuilder = null, $where = null) ->newQuery() ->delete() ->from($info->getTableName()) - ->where($where); + ->where($where) + ; } /** @@ -3562,7 +3559,6 @@ public function whereWithSpecification($specification) { // Do nothing } - return $persist; } diff --git a/src/MagicObject.php b/src/MagicObject.php index 282b0ab..a27a727 100644 --- a/src/MagicObject.php +++ b/src/MagicObject.php @@ -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; @@ -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 @@ -1198,7 +1184,6 @@ private function countData($persist, $specification, $pageable, $sortable, $find { $match = $persist->countAll($specification, $pageable, $sortable); } - return $match; }