mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 16:12:49 +08:00
改进模型类的get和all方法 第二个参数为true或者数字表示缓存参数
This commit is contained in:
@@ -328,7 +328,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
} elseif (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [
|
} elseif (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [
|
||||||
'datetime',
|
'datetime',
|
||||||
'date',
|
'date',
|
||||||
'timestamp'
|
'timestamp',
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
$value = $this->formatDateTime($_SERVER['REQUEST_TIME'], $this->dateFormat);
|
$value = $this->formatDateTime($_SERVER['REQUEST_TIME'], $this->dateFormat);
|
||||||
@@ -441,7 +441,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
if (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [
|
if (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [
|
||||||
'datetime',
|
'datetime',
|
||||||
'date',
|
'date',
|
||||||
'timestamp'
|
'timestamp',
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
$value = $this->formatDateTime(strtotime($value), $this->dateFormat);
|
$value = $this->formatDateTime(strtotime($value), $this->dateFormat);
|
||||||
@@ -1275,6 +1275,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public static function get($data = null, $with = [], $cache = false)
|
public static function get($data = null, $with = [], $cache = false)
|
||||||
{
|
{
|
||||||
|
if (true === $with || is_int($with)) {
|
||||||
|
$cache = $with;
|
||||||
|
$with = [];
|
||||||
|
}
|
||||||
$query = static::parseQuery($data, $with, $cache);
|
$query = static::parseQuery($data, $with, $cache);
|
||||||
return $query->find($data);
|
return $query->find($data);
|
||||||
}
|
}
|
||||||
@@ -1290,6 +1294,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public static function all($data = null, $with = [], $cache = false)
|
public static function all($data = null, $with = [], $cache = false)
|
||||||
{
|
{
|
||||||
|
if (true === $with || is_int($with)) {
|
||||||
|
$cache = $with;
|
||||||
|
$with = [];
|
||||||
|
}
|
||||||
$query = static::parseQuery($data, $with, $cache);
|
$query = static::parseQuery($data, $with, $cache);
|
||||||
return $query->select($data);
|
return $query->select($data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user