Reputation: 462
I am creating a web service for a firebase database. I need to execute a query to a procedure firebird. I do this using PHP with PDO in this way (This is my summarized code):
$instalacion = $_REQUEST['instalacion'];
$fecha = $_REQUEST['fecha'];
$inicio = date("m/d/Y",strtotime($fecha))." ".$_REQUEST['inicio'];
$fin = date("m/d/Y",strtotime($fecha))." ".$_REQUEST['fin'];
$reserva_annio = 0;
$reserva = 0;
$numero = 0;
$serie = '';
$annio = date("Y", strtotime($fecha));
$res=$dbh->query("execute procedure INS_CREA_RESERVA (date('m/d/Y',strtotime($fecha)), $inicio, $fin, $instalacion)
returning_values($reserva_annio, $reserva, $numero, $serie); ");
The procedure in my firebird is working ok, but this query return me this:
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: -104 Dynamic SQL Error SQL error code = -104 Token unknown - line 3, column 25 '0'
This error tells me that the part that is failing is the returning_values line. But in my firebird work fine.
It is possible that I need to install a library in the php.ini or somethins similar? I already activated this: extension=pdo_firebird, but don't work.
Any advice about my mistake? Thanks!
Upvotes: 0
Views: 830
Reputation: 462
After researching online, I have found that this can be done with a simpler select query. Requesting it to return data is no sense, and with php it can be done with a simple query similar to this:
$instalacion = $_REQUEST['instalacion'];
$fecha = $_REQUEST['fecha'];
$inicio = date("m/d/Y",strtotime($fecha))." ".$_REQUEST['inicio'];
$fin = date("m/d/Y",strtotime($fecha))." ".$_REQUEST['fin'];
$res=$dbh->query("select * from INS_CREA_RESERVA($fecha, $inicio, $fin, $instalacion)");
Note that the 'Where' clause must be replaced by brackets and pass parameters separated by commas.
Upvotes: 0
Reputation: 1954
Try
$dt=date('m/d/Y',strtotime($fecha));
$res=$dbh->query("execute procedure INS_CREA_RESERVA ('$dt', ......
Upvotes: 1