CakePHP Query Method Does Support Bind Parameters
Just came across a post from a few months ago where I stated that CakePhp doesn’t support bind parameters. I have learned since then that this is not true. Happily, it does support bind parameters. An example I have used successfully:
function query_bottom_count($bottom_value, $start_uts, $end_uts)
{
$sql = <<<XSQL
SELECT
REPLACE( SUBSTRING_INDEX( SUBSTRING_INDEX( last_result_url,
'://', -1 ) , '/', 1 ) , 'www.', '' ) AS domain,
COUNT( REPLACE( SUBSTRING_INDEX( SUBSTRING_INDEX( last_result_url, '://', -1 ) ,
'/', 1 ) , 'www.', '' ) ) AS hits
FROM queries as Query
WHERE insert_uts >= ?
AND insert_uts < ?
GROUP BY domain HAVING hits = ?;
XSQL;
$ParamList = array($start_uts, $end_uts, $bottom_value);
$Data = $this->query($sql, $ParamList);
if ( !$Data ) return 0;
return count($Data);
}
Just setting the record straight.