Example #1
0
function commitReplaceFile($file_id = 0, $contents)
{
    global $dbxlink;
    $query = $dbxlink->prepare('UPDATE File SET mtime = NOW(), contents = ?, size = LENGTH(contents), thumbnail = NULL WHERE id = ?');
    $query->bindParam(1, $contents, PDO::PARAM_LOB);
    $query->bindParam(2, $file_id);
    try {
        return $query->execute();
    } catch (PDOException $e) {
        throw convertPDOException($e);
    }
}
Example #2
0
function usePreparedInsertBlade($tablename, $columns)
{
    global $dbxlink;
    $query = "INSERT INTO {$tablename} (" . implode(', ', array_keys($columns));
    $query .= ') VALUES (' . questionMarks(count($columns)) . ')';
    // Now the query should be as follows:
    // INSERT INTO table (c1, c2, c3) VALUES (?, ?, ?)
    try {
        $prepared = $dbxlink->prepare($query);
        $prepared->execute(array_values($columns));
        return $prepared->rowCount();
    } catch (PDOException $e) {
        throw convertPDOException($e);
    }
}