mirror of
https://github.com/typecho/typecho.git
synced 2025-03-18 08:59:40 +01:00
fix pgsql
This commit is contained in:
parent
c422952c89
commit
38184ba5ba
@ -21,7 +21,7 @@ trait PgsqlTrait
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $lastTable = null;
|
||||
private $lastInsertTable = null;
|
||||
|
||||
/**
|
||||
* 清空数据表
|
||||
@ -70,7 +70,6 @@ trait PgsqlTrait
|
||||
{
|
||||
if (Db::INSERT == $action && !empty($table)) {
|
||||
$this->compatibleInsert = false;
|
||||
$this->lastTable = $table;
|
||||
|
||||
if (!isset($this->pk[$table])) {
|
||||
$resource = $this->query("SELECT
|
||||
@ -96,10 +95,11 @@ WHERE
|
||||
// 使用兼容模式监听插入结果
|
||||
if (isset($this->pk[$table])) {
|
||||
$this->compatibleInsert = true;
|
||||
$this->lastInsertTable = $table;
|
||||
$query .= ' RETURNING ' . $this->quoteColumn($this->pk[$table]);
|
||||
}
|
||||
} else {
|
||||
$this->lastTable = null;
|
||||
$this->lastInsertTable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ WHERE
|
||||
*/
|
||||
public function lastInsertId($resource, $handle): int
|
||||
{
|
||||
$lastTable = $this->lastTable;
|
||||
$lastTable = $this->lastInsertTable;
|
||||
|
||||
if ($this->compatibleInsert) {
|
||||
$result = $this->fetch($resource);
|
||||
|
@ -112,8 +112,7 @@ class Validate
|
||||
{
|
||||
return filter_var(
|
||||
$str,
|
||||
FILTER_VALIDATE_URL,
|
||||
FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
|
||||
FILTER_VALIDATE_URL
|
||||
) !== false;
|
||||
}
|
||||
|
||||
@ -269,12 +268,12 @@ class Validate
|
||||
$rules = empty($rules) ? $this->rules : $rules;
|
||||
|
||||
// Cycle through the rules and test for errors
|
||||
foreach ($rules as $key => $rules) {
|
||||
foreach ($rules as $key => $rule) {
|
||||
$this->key = $key;
|
||||
$data[$key] = (is_array($data[$key]) ? 0 == count($data[$key])
|
||||
: 0 == strlen($data[$key])) ? null : $data[$key];
|
||||
|
||||
foreach ($rules as $params) {
|
||||
foreach ($rule as $params) {
|
||||
$method = $params[0];
|
||||
|
||||
if ('required' != $method && 'confirm' != $method && 0 == strlen($data[$key])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user