I have the following PDO statement:
$stmt = $db->prepare("SELECT MAX(RID) FROM TEMP_ROUTE");
$stmt->execute();
$rid = $stmt->fetch(PDO::FETCH_ASSOC);
$rid = (int) $rid["MAX(RID)"];
Is there any way so that I don’t have to do the last statement there. In other words I want it to fetch $rid["MAX(RID)"] when doing the fetch.
Have a look at http://www.php.net/manual/en/pdostatement.bindcolumn.php and try using PDO::FETCH_BOUND instead perhaps? This won’t make it shorter though. Or try something like this, from http://www.php.net/manual/en/pdostatement.fetch.php: