954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HOw to write MYsql Query in cakephp

Hi,

how to write the MYSQL Query

select count(*) from (SELECT user_id FROM `reports` group by report_id) as tb where tb.user_id=5

in Cakephp inside the Loop

$users=$this->User->find('all');
    		
    		foreach($users as & $user):
                        //for each $user['User']['user_id']; which gives the User ids as 1 2 3 4 5 ...

              endforeach;

   			 $this->set('users', $users);
arunajasmine
Newbie Poster
18 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

You got the connection? try this-

$this->User->query("select count(*) from (SELECT user_id FROM `reports` group by report_id) as tb where tb.user_id=5");
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

There is no difference. In both cases the variable is not set.
But this one looks better

php Code:

Original - php Code
echo "<TD><a href="searchfromlist.php".$myrow[""]."">search another</a>";

   1.
       
   2.
      echo "<TD><a href="searchfromlist.php".$myrow[""]."">search another</a>";
marck_don
Light Poster
26 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: