Update dbinterface.class.php
Check that labels exist before binding or an exception will occur
This commit is contained in:
parent
03dd9bed5a
commit
e3116d39cb
|
@ -129,9 +129,15 @@ class dbinterface
|
||||||
$sql .= (empty($sql)) ? 'ref = :ref' : ' and ref = :ref';
|
$sql .= (empty($sql)) ? 'ref = :ref' : ' and ref = :ref';
|
||||||
}
|
}
|
||||||
if (!empty($sql)) {
|
if (!empty($sql)) {
|
||||||
$stmts = $dbh->prepare('SELECT * FROM sccpbuttonconfig WHERE ' .$sql. ' ORDER BY instance');
|
$stmts = $dbh->prepare("SELECT * FROM sccpbuttonconfig WHERE {$sql} ORDER BY instance");
|
||||||
$stmts->bindParam(':buttontype', $data['buttontype'],\PDO::PARAM_STR);
|
// Now bind labels - only bind label if it exists or bind will create exception.
|
||||||
$stmts->bindParam(':ref', $data['id'],\PDO::PARAM_STR);
|
// can only bind once have prepared, so need to test again.
|
||||||
|
if (!empty($data['buttontype'])) {
|
||||||
|
$stmts->bindParam(':buttontype', $data['buttontype'],\PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
if (!empty($data['id'])) {
|
||||||
|
$stmts->bindParam(':ref', $data['id'],\PDO::PARAM_STR);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$raw_settings = array();
|
$raw_settings = array();
|
||||||
}
|
}
|
||||||
|
@ -141,6 +147,7 @@ class dbinterface
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$raw_settings = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$raw_settings = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
} elseif (!empty($stmts)) {
|
} elseif (!empty($stmts)) {
|
||||||
|
dbug('statement is before execute', $stmts);
|
||||||
$stmts->execute();
|
$stmts->execute();
|
||||||
$raw_settings = $stmts->fetchAll(\PDO::FETCH_ASSOC);
|
$raw_settings = $stmts->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue