CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 RecordsCount in BeforeShow event.

Print topic Send  topic

Author Message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.