1
have a function but the same is not entering the if...
/**
* funcao que trocas os valores por "?"
* @param type $condicao : ex "codigo = 1, AND, nome = 2, OR, secao = 1" ou "codigo = 1, AND, nome = rafael" ou "codigo = 1";
* @return type ex: "codigo = ? AND nome = ? OR secao = ?"
*/
function prepareCondReadInterrogacao($condicao) {
$val = explode(",", $condicao);
$temp = "";
foreach ($val as $value) {
if (!strcmp($value, "AND") || !strcmp($value, "OR")) {
echo 'entrei';
$val2 = explode("=", $value);
$val2[1] = " ?";
$value = implode("=", $val2);
}
$temp .= $value . " ";
}
return $temp;
}
i need it to return me a string like : "code = ? AND name = ? OR secao = ?" where the entry is: "code = 1, AND, name = 2, OR, dry = 1"
– Rafael Silva
@Rafaelsilva ah, so just leave it out of the loop anyway. But the rest I think is right.
– Bacco
Fixed: http://ideone.com/9KCAyw
– Bacco
Then, if you test the second value whether it has quotes or not, you can already determine whether it is string or number, if you are going to bind.
– Bacco
Perfect guy, thank you very much! To going in leaps and bounds with php rsrs, my forte is java Android. I’m developing my web-server in the nail! Very tasty, I like challenges...
– Rafael Silva
All right, any questions about this problem, leave a comment, or others, open a new question, which we can help you with. The most important thing is that you understand what has been done, to reuse knowledge in future situations.
– Bacco