fix php 8.0 obselete function and add test for record

master
Jean-Christian Paul Denis 2021-09-05 00:41:10 +02:00
parent 6eaedd6791
commit 466f3cc126
1 changed files with 20 additions and 1 deletions

View File

@ -70,11 +70,21 @@ class epcRecords
if (!empty($params['epc_id'])) {
if (is_array($params['epc_id'])) {
array_walk($params['epc_id'], create_function('&$v,$k', 'if($v!==null){$v=(integer)$v;}'));
array_walk($params['epc_id'], function(&$v, $k) { if ($v !==null) { $v = (integer) $v; }});
} else {
$params['epc_id'] = [(integer) $params['epc_id']];
}
$strReq .= 'AND E.epc_id ' . $this->con->in($params['epc_id']);
} elseif (isset($params['not_id']) && is_numeric($params['not_id'])) {
$strReq .= "AND NOT E.epc_id = '" . $params['not_id'] . "' ";
}
if (isset($params['epc_key'])) {
if (is_array($params['epc_key']) && !empty($params['epc_key'])) {
$strReq .= 'AND E.epc_key ' . $this->con->in($params['epc_key']);
} elseif ($params['epc_key'] != '') {
$strReq .= "AND E.epc_key = '" . $this->con->escape($params['epc_key']) . "' ";
}
}
if (!empty($params['sql'])) {
@ -138,6 +148,15 @@ class epcRecords
$this->core->callBehavior('enhancePostContentAfterUpdRecord', $cur, $id);
}
public function isRecord($filter, $key, $not_id = null)
{
return 0 < $this->getRecords([
'epc_filter' => $filter,
'epc_key' => $key,
'not_id' => $not_id
], true)->f(0);
}
public function delRecord($id)
{
$id = (integer) $id;