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

Friday, April 22, 2022

[FIXED] how to display max and min number from database in cakephp

 April 22, 2022     cakephp, cakephp-1.3, cakephp-2.0, cakephp-2.1, cakephp-2.3     No comments   

Issue

how to display max and min number in cakephp controller part .

$rs = $this->Item->find('all' , array ('fields' => array('Max(Item.no) as no')));

I want max number of Item table .

I need to add some rand number to that and save it in new row .


Solution

Use below query

$rs = $this->Item->find('all' , array ('fields' => array('Max(Item.no) as no')));

This query will return max number in below format

Array
(
    [0] => Array
        (
            [no] => 27
        )

)

$max = $rs[0]['no'];


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

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