Maybe I'm just DUMB
|
| Posted: 10/23/2002, 6:35 PM |
|
Environment: CCS
Acomplishment: hide a table and its contents when 2 things occur ->
1) hide if the search form is not completely filled or it is the first time the user is entering the page;
2) hide if no records are returned by search form.
1) I accomplished in the following way: in the page 'AfterInitialize' event I added the following code in order to hide or show the table:
if (!strcmp(CCGetParam("s_first_param",""),"") ||
!strcmp(CCGetParam("s_second_param",""),""))
$DadosAluno->Visible = False;
2) I can't seem to be able (as usual with CCS.....) to do the most stupid thing, that is, to retrieve the information about how many records were retunred by the query (I have seen the 'counting sheep' example, it does not apply since it is CC).
I tried:
function Page_AfterInitialize() {
$DBtemporaryConnection = new clsDBMyConnection();
$select_count = "SELECT count(*) FROM ......";
$DBtemporaryConnection->query($select_count);
$DBtemporaryConnection->next_record();
...
}
By issuing a 'print_r($DBtemporaryConnection)' in order to see how it was filled after the execution of the query, I had the following info. As you can see, 'RecordsCount' is ZERO, although it is clearly shown that I had 2 records returned by my query at '[count(*)] => 2' and also by issuing the same query by hand to the database:
clsdbthemaconn Object
(
[SQL] =>
[Where] =>
[Order] =>
[Host] => localhost
[Database] => myDatabase
[User] => myUser
[Password] => myPassword
[Persistent] =>
[Auto_Free] => 0
[Debug] => 0
[Halt_On_Error] => yes
[Seq_Table] => db_sequence
[Record] => Array
(
[0] => 2
[count(*)] => 2
)
[Errno] => 0
[Error] =>
[type] => mysql
[revision] => 1.2
[Link_ID] => Resource id #1
[Query_ID] => Resource id #2
[AbsolutePage] => 0
[PageSize] => 0
[RecordsCount] => 0
[RecordNumber] => 0
[DateFormat] => Array
(
[0] => yyyy
[1] => -
[2] => mm
[3] => -
[4] => dd
[5] =>
[6] => HH
[7] => :
[8] => nn
[9] => :
[10] => ss
)
[BooleanFormat] => Array
(
[0] => 1
[1] => 0
[2] =>
)
[Errors] => clserrors Object
(
[Errors] => Array
(
)
[ErrorsCount] => 0
[ErrorDelimiter] => <br>
)
[Row] => 1
)
Any hints from the experts?
Thanks,
MAYBE I'M JUST DUMB
|
|
|
 |
xbill
|
| Posted: 10/24/2002, 7:28 AM |
|
From the example- it looks like the
source language is probably PHP.
(The count record names and variables are
different in each target language)
With some digging- the PHP equivalent in
CCS seems to be the RecordsCount value
on the datasource class inside the grid
object.
So- on a grid object, you can use code
something like:
$Label1 = $grid->ds->RecordsCount;
You may have to test a few different places to put
the event code to do the check -either on a Page
event or an event on the grid form.
You can also open up the generated code in the
code window and review the code. When you use
events with PHP- CCS puts all the custom event
code into a seperate file- but it is worth browsing
the main generated file- so you can see
when everything gets loaded and triggered.
-bill
|
|
|
 |
|