saseow
Posts: 744
|
| Posted: 02/17/2005, 5:43 PM |
|
I am getting a record count in the AfterExecuteSelect event using $live_participant_answers->ds->RecordsCount which is working well.
In some cases however, I want to get a count via code in the before shown event. Something like:
$db = new clsDBessa();
$SQL = "Select * from sometable";
$db->query($SQL);
Assign the resulting recordset to a variable and get the record count.
$db->close();
Is this possible?
Regards,
Trevor
|
 |
 |
Nicole
Posts: 586
|
| Posted: 02/18/2005, 5:15 AM |
|
Trevor,
Before Show event is fired after sql query is executed. So you can get the records count from RecordsCount property of form’s data source, e.g.
global $form_name;
echo $form_name->ds->RecordsCount;
_________________
Regards,
Nicole |
 |
 |
saseow
Posts: 744
|
| Posted: 02/18/2005, 6:07 AM |
|
Hi Nicole,
Thanks for this but I want to get the record count BEFORE the SQL is created. The reason is that if the count is 0, then I create 100 predefined records for that user.
Regards,
Trevor
|
 |
 |
klwillis
Posts: 428
|
| Posted: 02/23/2005, 11:42 AM |
|
You can do something like this ...
global $DBessa;
$record_count = CCDLookup("select count(*) as record_count","sometable","",$DBessa);
Quote saseow:
Hi Nicole,
Thanks for this but I want to get the record count BEFORE the SQL is created. The reason is that if the count is 0, then I create 100 predefined records for that user.
Regards,
Trevor
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"
Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006 |
 |
 |
saseow
Posts: 744
|
| Posted: 02/23/2005, 8:11 PM |
|
Hi klwillis,
Very neat. Thank you for this. what I ended up doing is:
$userid = CCGetSession("UserID","");
$db = new clsDBessa();
$Result = CCDLookUp("user_id", "participant_answers", "user_id = ".$userid, $db);
if ($Result == "")//No records found so create 100
{ etc etc
Thanks again,
Trevor
|
 |
 |
klwillis
Posts: 428
|
| Posted: 02/24/2005, 10:58 AM |
|
I'm glad it worked for you - CCDLookup is very flexible. 
Quote saseow:
Hi klwillis,
Very neat. Thank you for this. what I ended up doing is:
$userid = CCGetSession("UserID","");
$db = new clsDBessa();
$Result = CCDLookUp("user_id", "participant_answers", "user_id = ".$userid, $db);
if ($Result == "")//No records found so create 100
{ etc etc
Thanks again,
Trevor
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"
Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006 |
 |
 |
|