php - Variable binding in aura/sqlquery when using mysqli_* connection -
i've got legacy app uses mysqli_*() functions (actually, uses mysql_*() functions. gah!). using aura/sqlquery sql query generator. example:
$queryfactory = new aura\sqlquery\queryfactory('mysql'); $select = $queryfactory->newselect(); $select->from('sometable t') ->where('t.field1 = 0') ->where("t.field2 <> ''"); then raw sql casting string:
$sql = (string) $select; now want do variable binding in where():
$select->where('t.somefield = ?', $somevalue); when cast string, escaping/binding never seems occur. appears binding takes place when 1 uses pdo , prepared statements.
any ideas how variable binding in aura/sqlquery when using mysqli connection?
if php version >= 5.6, here function can use run query aura/sqlquery against mysqli
function mysqli_query_params($mysqli, $query, $params, $types = null) { $statement = $mysqli->prepare($select); $types = $types ?: str_repeat('s', count($params)); $statement->bind_param($types, ...$params); $statement->execute(); return $statement; } used this
mysqli_query_params($mysqli, $select->getstatement(), $select->getbindvalues())
Comments
Post a Comment