snarf
Posts: 14
|
| Posted: 01/05/2005, 7:02 AM |
|
Strange problem that we have not encountered before. We have an application that uses two databases -- 'events' and 'core'. The objects created are $DBevents and $DBcore.
Both work fine throughout the application until recently when we tried to create a custom query to 'core' from within a record form based on 'events' (looking up some configuration details).
Within the function we're setting $DBcore to a global scope. We're using the query() method on the $DBcore object. $DBevents should not even be visible within the function, and even if it were in-scope, we never call it within this function.
The problem is that when we run the test query:
$DBcore->query("SELECT * FROM tableX");
We get this from mySQL:
Table 'events.tableX' doesn't exist
So for some reason, our query using the object created for the 'core' database is actually selecting the 'events' database (or is somehow getting to the wrong place). To make sure we weren't crazy, we did
print_r($DBcore)
right before that query() method, and everything was 100% as it should be.
So it looks like something is getting confused about which mySQL handle to latch onto... could be PHP, mySQL, whatever CCS is using for DB abstraction, etc.
Has anyone seen this before? Any info appreciated.
Here's what the whole thing looks like:
function scheduledJobs1_jobSourceID_BeforeShow()
{
$scheduledJobs1_jobSourceID_BeforeShow = true;
//End scheduledJobs1_jobSourceID_BeforeShow
//Custom Code @127-BAE32536
// -------------------------
global $DBcore;
global $scheduledJobs1;
$SQL = "SELECT * FROM tableX WHERE JobID = " . CCGetFromGet('JobID');
#print_r($DBcore); // for debugging
$resultSet = $DBcore->query($SQL);
$scheduledJobs1->jobName->SetValue('iScan: ' . $DBcore->f('jobName'));
$scheduledJobs1->jobDescriptionID->SetValue($DBcore->f('Comments'));
$scheduledJobs1->jobCommand->SetValue($DBcore->f('ExecutablePath'));
}
// -------------------------
//End Custom Code
|
 |
 |
snarf
Posts: 14
|
| Posted: 01/05/2005, 7:18 AM |
|
Just a quick update -- we changed everything to use PHP's native mysql calls instead of CCS's database abstraction layer and everything works find. This would seem to indicate a problem with the abstraction layer. 
Does this spark any additional ideas with anyone?
|
 |
 |
Proton
|
| Posted: 01/09/2005, 2:03 AM |
|
I know this problem.
When I have more then one database in one script, I don't use default objects, rather then I create my own from DB classes. In your subject it will be:
$myDBevents = new clsDBevents;
$myDBcore = new clsDBcore;
And from this point I use $myDBevents and $myDBcore.
But I saw one more problem. From time to time it dosn't work properly. Espetially when I mixing DB queries like:
$myDBevents->query($sql1);
$myDBcore->query($sql2);
$myDBevents->query($sql3);
$myDBcore->query($sql4);
Then you have to probe to order your questions like:
$myDBevents->query($sql1);
$myDBevents->query($sql3);
$myDBcore->query($sql2);
$myDBcore->query($sql4);
(I'm sorry for my english)
|
|
|
 |
snarf
Posts: 14
|
| Posted: 01/09/2005, 10:05 AM |
|
Proton, that's extremely helpful -- I will try that. That's what I do when I am hand-coding, but I wasn't sure if that would mangle CCS. I will try the seperate-object approach and see what happens.
Thanks!!
PS - your english is fine.
|
 |
 |
|