mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 15:45:36 +08:00
update to 2.3.1 version (build 388)
cleanup code and fix a bug
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php /** @noinspection PhpComposerExtensionStubsInspection */
|
||||
<?php /** @noinspection PhpUnused */
|
||||
|
||||
/** @noinspection PhpComposerExtensionStubsInspection */
|
||||
|
||||
|
||||
namespace ZM\DB;
|
||||
@@ -34,7 +36,7 @@ class DB
|
||||
* @return Table
|
||||
* @throws DbException
|
||||
*/
|
||||
public static function table($table_name) {
|
||||
public static function table($table_name): Table {
|
||||
if (Table::getTableInstance($table_name) === null) {
|
||||
if (in_array($table_name, self::$table_list))
|
||||
return new Table($table_name);
|
||||
@@ -60,7 +62,7 @@ class DB
|
||||
* @return bool
|
||||
* @throws DbException
|
||||
*/
|
||||
public static function unprepared($line) {
|
||||
public static function unprepared($line): bool {
|
||||
try {
|
||||
$conn = SqlPoolStorage::$sql_pool->get();
|
||||
if ($conn === false) {
|
||||
@@ -134,7 +136,7 @@ class DB
|
||||
}
|
||||
}
|
||||
|
||||
public static function isTableExists($table) {
|
||||
public static function isTableExists($table): bool {
|
||||
return in_array($table, self::$table_list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class SelectBody
|
||||
/**
|
||||
* @throws DbException
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
$this->select_thing = ["count(*)"];
|
||||
$str = $this->queryPrepare();
|
||||
$this->result = DB::rawQuery($str[0], $str[1]);
|
||||
@@ -81,7 +81,7 @@ class SelectBody
|
||||
|
||||
public function getResult() { return $this->result; }
|
||||
|
||||
public function equals(SelectBody $body) {
|
||||
public function equals(SelectBody $body): bool {
|
||||
if ($this->select_thing != $body->getSelectThing()) return false;
|
||||
elseif ($this->where_thing == $body->getWhereThing()) return false;
|
||||
else return true;
|
||||
@@ -95,9 +95,9 @@ class SelectBody
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getWhereThing() { return $this->where_thing; }
|
||||
public function getWhereThing(): array { return $this->where_thing; }
|
||||
|
||||
private function queryPrepare() {
|
||||
private function queryPrepare(): array {
|
||||
$msg = "SELECT " . implode(", ", $this->select_thing) . " FROM " . $this->table->getTableName();
|
||||
$sql = $this->table->paintWhereSQL($this->where_thing['='] ?? [], '=');
|
||||
if ($sql[0] != '') {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
<?php /** @noinspection PhpUnused */
|
||||
|
||||
/** @noinspection PhpMissingReturnTypeInspection */
|
||||
|
||||
|
||||
namespace ZM\DB;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php /** @noinspection PhpMissingReturnTypeInspection */
|
||||
|
||||
|
||||
namespace ZM\DB;
|
||||
|
||||
Reference in New Issue
Block a user