I am trying to decipher a particular statement that is in PHP program that is doing a Mysql query. The query has ?: and ? in it. What is there function?
$data = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'A'", $order_id);
Thanks for any help.
Chris
They look like placeholders for prepared statements. You provide the
?where you will later provide an actual value. Consider this example from the PHP documentation:Source: http://php.net/manual/en/pdo.prepared-statements.php
Your particular example appears to be from CS-Cart. For instance, according to their documentation
?iforces the value passed into that placeholder to be converted to an integer (this is similar to the waysprintfworks).In the above case,
$numberis treated as an integer. If I tried to pass a string into that slot, I’d get very different results:Note here how my types didn’t match up, and therefore
0replacedcompletedin the output.Bottom line, these are placeholders.