Ok, first of all I have very little clue how to use php, and only a slightly better understanding of sql. So if anything I do appears really, really stupid, please bear with me.
Given a user input of a date, a time and a time interval, I need to get two timestamps without timezones - a starting time, and an endtime. e.g.
function myfunction($startdate, $starttime, $numhours){
$start = $startdate.' '.$starttime;
//I know this works for a timestamp because I have used this value in other sql statements and have been returned the correct results
$handler = $connection->prepare("SELECT TIMESTAMP :start + INTERVAL :numhours ' HOURS'");
$handler->bindParam(':start', $start);
$handler->bindParam(':numhours', $numhours);
$handler->execute();
$end = $handler->fetchAll();
This just gets me the following error:
Submitting booking.SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1" LINE 1: SELECT TIMESTAMP $1 + INTERVAL $2 ' HOURS'
I haven't been able to find anything that really tells me what I'm doing wrong here (which is probably a lot). Help is appreciated.
EDIT: I'm using postgreSQL, through `pgAdmin III
EDIT: $start should have the form 'YYYY-MM-DD HH:MM:SS'
$startand$numhours?INTERVAL '3 hours'orINTERVAL '3' HOUR(instead ofINTERVAL '3' ' HOURS')