20231010#2
This commit is contained in:
@@ -107,10 +107,12 @@ class MysqlStorage implements MysqlStorageInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
public function read(string $sql, int $ln = 0, int $numPage = 1) : bool|MysqlStorageData {
|
public function read(string $sql, int $ln=0, int $numPage=1, int $count=0): bool|MysqlStorageData {
|
||||||
|
|
||||||
if ($ln > 1) {
|
if ($ln > 1) {
|
||||||
$cnts = $this->query($sql)->num_rows;
|
$cnts = (!empty($count)) ? $count : $this->query($sql)->num_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
// часть строки запроса с лимит
|
// часть строки запроса с лимит
|
||||||
switch (true){
|
switch (true){
|
||||||
case ($ln > 1 || $numPage > 1) : $limit = " limit ".(($numPage * $ln) - $ln).", ".$ln; break;
|
case ($ln > 1 || $numPage > 1) : $limit = " limit ".(($numPage * $ln) - $ln).", ".$ln; break;
|
||||||
@@ -123,9 +125,12 @@ class MysqlStorage implements MysqlStorageInterface {
|
|||||||
|
|
||||||
$data = new MysqlStorageData($result);
|
$data = new MysqlStorageData($result);
|
||||||
$data->count = $cnts ?? 0;
|
$data->count = $cnts ?? 0;
|
||||||
|
$data->hex = md5($sql);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
public function chktbl(string $tbl) : bool {
|
public function chktbl(string $tbl) : bool {
|
||||||
$result = $this->mysqli->query("SHOW TABLES LIKE '".$this->escapeStr($tbl)."'");
|
$result = $this->mysqli->query("SHOW TABLES LIKE '".$this->escapeStr($tbl)."'");
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class MysqlStorageData {
|
|||||||
private ?\mysqli_result $result;
|
private ?\mysqli_result $result;
|
||||||
private array $arrayData = [];
|
private array $arrayData = [];
|
||||||
public int $count;
|
public int $count;
|
||||||
|
public string $hex = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MysqlDataObject constructor.
|
* MysqlDataObject constructor.
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ interface MysqlStorageInterface {
|
|||||||
* @param int $count
|
* @param int $count
|
||||||
* @return bool|MysqlStorageData
|
* @return bool|MysqlStorageData
|
||||||
*/
|
*/
|
||||||
public function read(string $sql, int $ln = 0, int $numPage = 1) : bool|MysqlStorageData;
|
public function read(string $sql, int $ln = 0, int $numPage = 1, int $count=0) : bool|MysqlStorageData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $tbl
|
* @param string $tbl
|
||||||
|
|||||||
Reference in New Issue
Block a user