I was reading a book about PHP and saw this code for inserting records. I do not understand a specific expression in the default case of the ternary operator. More specifically:
"'$v',"
Did the author make a mistake using single quotes (') and what he really meant were the backticks(`) to quote a soecial mysql expression? Why would you use single quotes and then double quotes on a variable?
According to the mysql documentation :
"The identifier quote character is the backtick (“`”): " http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
public function insertRecords($table, $data){
//setup some variables for fields and values
$fields = "";
$values = "";
//populate them
foreach($data as $f => $v){
$fields .= "`$f`,";
$values .= (is_numeric($v) && (intval($v) == $v)) ? $v . "," : "'$v',";
}
}