fixed pgsql db issue;close #38

This commit is contained in:
huangjx
2022-03-20 16:39:50 +08:00
parent f6eb5eae52
commit 2ec569e2b5
3 changed files with 22 additions and 4 deletions

View File

@@ -124,4 +124,18 @@ class DbHelper
return $query->execute();
}
public function getDBType(): string
{
return \OC::$server->getConfig()->getSystemValue('dbtype', "mysql");
}
public function getExtra($data)
{
if ($this->getDBType() == "pgsql" && is_resource($data)) {
$extra = pg_unescape_bytea(stream_get_contents($data));
return unserialize($extra);
}
return unserialize($data);
}
}

View File

@@ -57,6 +57,10 @@ class YoutubeHelper
$this->gid = Helper::generateGID($extra['link']);
$file = $this->getFilePath($buffer);
if ($file) {
$extra = serialize($extra);
if($this->dbconn->getDBType() == "pgsql"){
$extra = pg_escape_bytea($extra);
}
$data = [
'uid' => $this->user,
'gid' => $this->gid,
@@ -64,7 +68,7 @@ class YoutubeHelper
'filename' => basename($file),
'status' => Helper::STATUS['ACTIVE'],
'timestamp' => time(),
'data' => serialize($extra),
'data' => $extra,
];
//save the filename as this runs only once
$this->file = $file;