Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$test = array(10,20); $rez = $this->Schimb->query("SELECT `pret`,`valuta` FROM schimb ORDER BY pret*{$test['valuta']} DESC");
我无法将数组中的值插入到 MySQL Query 中……问题出在哪里?
问题可能是您试图将常规数组用作关联数组(在这种情况下由字符串键索引)。尝试使用数组位置作为键。
$test[0], $test[1] etc...
例子:
$rez = $this->Schimb->query("SELECT `pret`,`valuta` FROM schimb ORDER BY pret{$test[0]} DESC");
但是,您是否应该只ORDER BY使用 pret 列呢?
ORDER BY