Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Using SQL Aggregate Functions (How to use MAX, AVE, SUM, etc.)
Re: Using SQL Aggregate Functions [message #1289 is a reply to message #1286] Thu, 13 March 2008 07:41 Go to previous messageGo to previous message
AJM is currently offline  AJM
Messages: 2361
Registered: April 2006
Location: Surrey, UK
Senior Member
If you look inside the _cm_getInitialData() method of file crs_student.class.inc you will see that I use the following code:
$count = $this->getCount("SELECT max(student_id) FROM $this->tablename");
$fieldarray['student_id'] = $count + 1;

I have also tried the following code with exactly the same result:
$this->sql_select = "MAX(student_id) AS last_id";
$rows=$this->getdata_raw();
$count = $rows[0]['last_id'];

I prefer the first method as it requires less code.


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: creating list items
Next Topic: How do you deploy your app?
Goto Forum:
  


Current Time: Fri Sep 27 03:26:59 EDT 2024

Total time taken to generate the page: 0.19649 seconds