PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 21, 2022

[FIXED] how to get fetch value in cakephp

 April 21, 2022     cakephp, cakephp-2.0, cakephp-2.1, cakephp-2.3     No comments   

Issue

        $map=$this->Sessiondetails->find("all");    
        $this->set("map",$map);
    foreach($map as $maps){ 
   echo $maps['Sessiondetails']['latitude'];
    }

I want to fetch only 3rd row values . How to do it in cakephp. I am using cakephp 2x.


Solution

How would you do it in SQL? Think about it and then use cake syntax

http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#retrieving-your-data

$map = $this->Sessiondetails->find(
    "all"
    array(
        'offset' => 2
        'limit' => 1
    )
);   

of course if you want to run a query that retrieves all the records but then just show the 3rd record you can simply do

echo $map[2]['Sessiondetails']['latitude'] 


Answered By - arilia
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing