[Solved] Using Cake PHP Sort to sort Array Keys

You cannot sort an simple array by his key in cake. You can only sort like this: (or you can use {n}.{n} ) $array = (e,h,u,w,r); $result = Set::sort($array, ‘{n}’, ‘asc’); pr($result); For key sorting use ksort php function, or create in cake a ksort function with same properties and use it ksort( $array ); … Read more

[Solved] CakePHP 3.0 and new project [duplicate]

I’ve been working a lot with Cakephp 2, and i’m currently learning Cakephp 3. What I can say so far is: cakephp 3 introduces a lot a interesting new functionnalities (i won’t detail here, you can find many resources on internet for that). cakephp 3 is really a major release: many things have changed. Even … Read more

[Solved] How to write REST web service in cakephp using Post ..? [closed]

you can sent json through Http post in cakephp <?php $data = array(‘Users’=>array(‘id’=>’1′,’username’=>’xyz’,’password’=>’pass’,’email’=>’[email protected]’,’age’=>’28’,’gender’=>’male’)); $url = “http://localhost/appname/Controllername/functionname”; $content = json_encode($data); $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, ‘data=”.$content); $json_response = curl_exec($curl); echo $json_response;?> 2 solved How to write REST web service in cakephp using Post ..? [closed]

[Solved] how to create form with a drop-down list that change the other option depend on selection [duplicate]

I’m trying to find a specific solution for cakePHP but I got bullied instead of getting a good answer. After a lot of searching I’ve found this great blog post which exactly solve my problem. http://blog.jandorsman.com/2011/01/using-ajax-and-cakephp-to-dynamically-populate-select-form-fields/ If you’re using a newer version of CakePHP. you need to use different functions JS helper instead $this->Js->get(‘#BookId’)->event( ‘change’, … Read more

[Solved] Output last 5 rows in database [CakePHP] [closed]

You have to use find() Other way is to use query() $alltext = $this->Text->find(‘all’, array(‘limit’ => 5,’order’=>array(‘id DESC’))); <?php foreach ($alltextext as $text): ?> // format as necessary <td><?php echo $text[‘Text’][‘id’]; ?></td> // add others here <?php endforeach; ?> 3 solved Output last 5 rows in database [CakePHP] [closed]

[Solved] Protect folders in CakePHP2

CakePHP does this automatically. If you try to access www.yoursite.com/css, it will try to access the “CssController”, which doesn’t exists, so it will throw an error – it won’t show your folder contents. The same goes for the rest. 2 solved Protect folders in CakePHP2