Custom Order By in CakePHP
// In mysql you can order by specific field values, by using ORDER BY FIELD:
SELECT * FROM city
WHERE id IN (10, 1, 2)
ORDER BY FIELD(id, 10, 1, 2) DESC;
// output:
// order: first those with id = 10, those with id = 1, those with id = 2
// Do in cake
'order' => array(
'FIELD(City.id, 10, 1, 2)',
),
// or
'order' => array(
'FIELD(City.id, 10, 1, 2) DESC',
),
Also in PHP:
- array filter remove duplicates multidimensional php
- base64 decode php function
- error reportin eall
- console.log for php
- ALTER table laravel
- clear all cache laravle
- date ('n')
- apagar cache laravel
- check if key exists in the array
- check if php contains string
- array_unique spip
- Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of
- This behaviour is (currently) not supported by Doctrine 2
- extend woocommerce user fields edit-account
- confirm before submit form php
- check that array key exists
- error display
- Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
- decode base64 image php
- array reverse array php
- add variable days to datsphp
- do_shortcode
- composer php version
- date_create php format