pdo statement->execute expects either the prepared statement with already bound parameters OR an array of the vars to be bound. It can NOT handle them MIXED

This commit is contained in:
Klaus Leithoff 2010-03-04 12:05:42 +00:00
parent 3e33651c5d
commit 7e34a7c999

View File

@ -326,18 +326,26 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
if ($this->operation == self::STORE2FS)
{
$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_size=:fs_size,fs_mime=:fs_mime,fs_modifier=:fs_modifier,fs_modified=:fs_modified WHERE fs_id=:fs_id');
if (!($ret = $stmt->execute($values)))
{
error_log(__METHOD__."() execute() failed! errorInfo()=".array2string(self::$pdo->errorInfo()));
}
}
else
{
$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_size=:fs_size,fs_mime=:fs_mime,fs_modifier=:fs_modifier,fs_modified=:fs_modified,fs_content=:fs_content WHERE fs_id=:fs_id');
$this->stream_seek(0,SEEK_SET); // rewind to the start
$stmt->bindParam('fs_content', $this->opened_stream, PDO::PARAM_LOB);
foreach($values as $name => &$value)
{
$stmt->bindParam($name,$value);
}
if (!($ret = $stmt->execute($values)))
$stmt->bindParam('fs_content', $this->opened_stream, PDO::PARAM_LOB);
if (!($ret = $stmt->execute()))
{
error_log(__METHOD__."() execute() failed! errorInfo()=".array2string(self::$pdo->errorInfo()));
}
}
}
$ret = fclose($this->opened_stream) && $ret;
unset(self::$stat_cache[$this->opened_path]);