CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Dynamically modify the where clause

Print topic Send  topic

Author Message
jcode

Posts: 6
Posted: 03/09/2008, 12:49 PM

What I am trying to do is dynamicaly modify the where clause. I added the event to the before build select clause to try an achive this, but every time I create the live page, the event clause doe not appear to work. Here is the sample of the php code.

function Tasks_DataSource_BeforeBuildSelect(& $sender) {
global $Tasks;

if ($Tasks->DataSource->Where <> "") {
$Tasks->DataSource->Where .= " AND ";
}

$Tasks->DataSource->Where .= "ddaltx like 'H%'";

}

Any help would be great.

The field ddaltx is a description character field.
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/10/2008, 4:51 AM

The event: BeforeBuildSelect is correct.
The simple way (although your code looks ok ) would be:
  
  
function tasks_ds_BeforeBuildSelect(& $sender)  
{  
    $tasks_ds_BeforeBuildSelect = true;  
    $Component = & $sender;  
    $Container = & CCGetParentContainer($sender);  
    global $tasks; //Compatibility  
//End tasks_ds_BeforeBuildSelect  
  
//Custom Code @23-2A29BDB7  
// -------------------------  
    // Write your own code here.  
// -------------------------  
  $Component->ds->Where.='ddaltx like "H%" '  
  
  echo 'debug : '.  $Component->ds->Where; // debugging should show up in your browser  
  
//End Custom Code  
  
//Close tasks_ds_BeforeBuildSelect @9-EA0279C8  
    return $tasks_ds_BeforeBuildSelect;  
}  
//End Close tasks_ds_BeforeBuildSelect  

2 things:
1/ add the echo statement as I write, and it will display the set value of the Where clause.
2/ What version of CCS (Me 3.+ and 4.+) do you use as the BeforeBuildSelect seems to differ from the one you describe.
Also note I intechanged the single and double quotes......., the spaces are for readability.

Walter




_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
idh63

Posts: 76
Posted: 03/10/2008, 5:46 PM

jcode,

I had the same problem and I actually do things a little differently than Walter to discover the problem. it has become my first weapon of choice when I need to see the resulting sql.

Open db_mysql.php in your favourite editor. (I use Zend Studio, but Crimson Editor or similar would work great also).

Line 27: public $Debug = 0; ## Set to 1 for debugging messages.

Change this value to = 1 to see the mysql output to the screen.

I am using CCS4 and I discovered that the sql in the parameter box was overriding the Before Build Select. I had to use Before Execute Select. If I removed the sql from the parameters box and used before Build select with the same sql save the where clause, I got a ton of errors.

Walter has a lot more experience that I do with CCS and may be able to shed more light on your problem that I can.
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.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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