Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e384e2071 | ||
|
|
368ccfa44b | ||
|
|
f0f862d979 | ||
|
|
c43f3a4768 |
@@ -7,15 +7,15 @@ DB component for **Rmphp**
|
||||
Stable version
|
||||
|
||||
```bash
|
||||
composer require rmphp/kernel
|
||||
composer require rmphp/storage
|
||||
```
|
||||
```bash
|
||||
composer require rmphp/kernel:"^1.0"
|
||||
composer require rmphp/storage:"^2.0"
|
||||
```
|
||||
|
||||
|
||||
Dev version contains the latest changes
|
||||
|
||||
```bash
|
||||
composer require rmphp/kernel:"1.x-dev"
|
||||
composer require rmphp/storage:"2.x-dev"
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Rmphp\Storage\Exception;
|
||||
namespace Rmphp\Storage\Mysql\Exception;
|
||||
|
||||
|
||||
class MysqlException extends \Exception {
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Rmphp\Storage;
|
||||
namespace Rmphp\Storage\Mysql;
|
||||
|
||||
use Exception;
|
||||
use Mysqli;
|
||||
@@ -107,10 +107,12 @@ class MysqlStorage implements MysqlStorageInterface {
|
||||
}
|
||||
|
||||
/** @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) {
|
||||
$cnts = $this->query($sql)->num_rows;
|
||||
$cnts = (!empty($count)) ? $count : $this->query($sql)->num_rows;
|
||||
}
|
||||
|
||||
// часть строки запроса с лимит
|
||||
switch (true){
|
||||
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->count = $cnts ?? 0;
|
||||
$data->hex = md5($sql);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @inheritDoc */
|
||||
public function chktbl(string $tbl) : bool {
|
||||
$result = $this->mysqli->query("SHOW TABLES LIKE '".$this->escapeStr($tbl)."'");
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Rmphp\Storage;
|
||||
namespace Rmphp\Storage\Mysql;
|
||||
|
||||
|
||||
class MysqlStorageData {
|
||||
@@ -8,6 +8,7 @@ class MysqlStorageData {
|
||||
private ?\mysqli_result $result;
|
||||
private array $arrayData = [];
|
||||
public int $count;
|
||||
public string $hex = "";
|
||||
|
||||
/**
|
||||
* MysqlDataObject constructor.
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Rmphp\Storage;
|
||||
namespace Rmphp\Storage\Mysql;
|
||||
|
||||
interface MysqlStorageInterface {
|
||||
|
||||
@@ -57,7 +57,7 @@ interface MysqlStorageInterface {
|
||||
* @param int $count
|
||||
* @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
|
||||
Reference in New Issue
Block a user