1
in mysql I can do so.
SELECT * FROM `Cidade` ORDER BY `id`=1347 DESC
But I can’t do it in codeigniter, I’m trying it like this:
$this->db->order_by("id = 1347", "DESC")
->get("Cidades");
In this case his exit is being so:
SELECT * FROM `Cidade` ORDER BY `id=1347` DESC
he’s putting a bloquote on the whole expression. there’s no funnel. Thanks for helping out.
Have you tried it like this:
order_by("
id", "1347", "DESC")
– Tiedt Tech
pq has that number? wouldn’t just be the column name?
– rray
order_by("id", " = 1347 DESC")
– Marco Souza
is the id. It serves to put some more important cities at the top. example, Fortaleza is the capital, but in the natural order it is there by the middle. I’d like her to stay on top, because she’ll be the most used. mysql accepts this type of order_by, but I can’t do it in codeigniter. I have tried this order_by("id", "1347", "DESC"), but it does not roll, I think I will have to write the same sql.
– Thiago Lima
Here it worked exactly as you want it to $c = $this->db->order_by("id = 1347 DESC")->get("City"); var_dump($c->result_array()). You can test it for me and see if it’s anything related to the version?
– user1811893
So it did not function. it returned it:
SELECT * FROM \
City` ORDER BY `id =` 1347 DESC` it puts the = in the bloquote– Thiago Lima