no message
This commit is contained in:
parent
b22ea6ccc6
commit
d2e12a3d79
@ -441,6 +441,56 @@ class Dog extends Mod\Base {
|
||||
return $iLimit;
|
||||
}
|
||||
|
||||
public function last()
|
||||
{
|
||||
$iLastId = $this->oModelSelf->orderBy("id", "desc")->first()?->id;
|
||||
|
||||
$aParam = [];
|
||||
$aParam["aOption"][1] = "id";
|
||||
$aParam["aArg"][1] = $iLastId;
|
||||
|
||||
return $this->find($aParam);
|
||||
}
|
||||
|
||||
public function hitRaw($aParam)
|
||||
{
|
||||
$xId = $aParam["aArg"][1] ?? false;
|
||||
$sField = $aParam["aOption"][1] ?? false;
|
||||
|
||||
if (!$xId) {
|
||||
return "需要id";
|
||||
}
|
||||
|
||||
if (!$sField) {
|
||||
return "需要field";
|
||||
}
|
||||
|
||||
if ($xId == "?") {
|
||||
return "#hitRaw__[field] [id]";
|
||||
}
|
||||
|
||||
$sContent = $this->oModelSelf->where("id", $xId)->first()?->{$sField};
|
||||
|
||||
return $sContent;
|
||||
}
|
||||
|
||||
public function findRaw($aParam)
|
||||
{
|
||||
$xId = $aParam["aArg"][1] ?? false;
|
||||
|
||||
if (!$xId) {
|
||||
return "需要id";
|
||||
}
|
||||
|
||||
if ($xId == "?") {
|
||||
return "#findRaw [id]";
|
||||
}
|
||||
|
||||
$aData = $this->oModelSelf->where("id", $xId)->first()->toArray();
|
||||
|
||||
return $this->toJson($aData);
|
||||
}
|
||||
|
||||
public function find($aParam)
|
||||
{
|
||||
$sField = $aParam["aOption"][1] ?? $this->sPrimaryKey;
|
||||
@ -538,6 +588,9 @@ class Dog extends Mod\Base {
|
||||
|
||||
public function toJson($aData)
|
||||
{
|
||||
if (is_string($aData)) {
|
||||
return $aData;
|
||||
}
|
||||
|
||||
if ($this->aMsg && !is_string($aData)) {
|
||||
if (is_object($aData)) {
|
||||
@ -648,6 +701,38 @@ class Dog extends Mod\Base {
|
||||
return $this->set($aParam);
|
||||
}
|
||||
|
||||
public function jsonSet($aParam)
|
||||
{
|
||||
$iId = $aParam["aOption"][1] ?? "";
|
||||
$sField = $aParam["aOption"][2] ?? "";
|
||||
$aJson = $aParam["aArg"];
|
||||
$sJson = implode(" ", $aJson);
|
||||
$aJson = json_decode($sJson, true);
|
||||
|
||||
if ($sJson == "?") {
|
||||
return "#jsonSet__[id]__[field] [json]";
|
||||
}
|
||||
|
||||
if (!$iId || !$sField || !$sJson) {
|
||||
return "参数不足";
|
||||
}
|
||||
|
||||
$oModelSelf = $this->oModelSelf->where("id", $iId)->first();
|
||||
|
||||
if (!$oModelSelf) {
|
||||
return "没有这个";
|
||||
}
|
||||
|
||||
$oModelSelf->$sField = $aJson;
|
||||
$oModelSelf->save();
|
||||
|
||||
$aParam = [];
|
||||
$aParam["aOption"][1] = "id";
|
||||
$aParam["aArg"][1] = $iId;
|
||||
|
||||
return $this->find($aParam);
|
||||
}
|
||||
|
||||
public function arrUnset($aParam)
|
||||
{
|
||||
$aParam["sCmd"] = "unset";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user