I use Oracle as a database layer, but the problem is that oracle via OCI8 (i made a PDO userspace driver) only supports named parameters in SQL statements and doesn't support positioned parameters. (Such as using multiple ?)
At a base, it's Laravel's Eloquent, that generates the SQL, but i can't find any documentation on how to override the construction of parameters.
I'd like to be able to create named parameters in the form of ":name" instead of placing numerous "?" throughout the query.
Can this be done? My guess is it has something to do with the Database Grammar classes...
Oh well, if someone has a better solution, go ahead a submit it or maybe tell me what could be wrong with my temporary solution. I replace all "?" with ":autoparam" with a parameter increment creating ":autoparam0", ":autoparam1", ":autoparam2", etc.
//Replace ? with a pseudo named parameter
$newStatement = null;
$parameter = 0;
while($newStatement !== $statement)
{
if($newStatement !== null)
{
$statement = $newStatement;
}
$newStatement = preg_replace('/\?/', ':autoparam'.$parameter, $statement, 1);
$parameter++;
}
$statement = $newStatement;
Then, when i receive a request to bind a parameter from PDO, i check if the parameter is numeric. In most languages, as far as i know, numeric indexes are invalid identifiers, so i can safely assume, at least for my PDO Userspace driver that i can replace the numeric parameter name with:
//Replace the first @oci8param to a pseudo named parameter
if(is_numeric($parameter))
{
$parameter = ':autoparam'.$parameter;
}
It works for now, i need to do more tests with laravel to see if problem appears in a different score, but so far, it seems allright...