jim7567g
Posts: 38
|
| Posted: 03/03/2005, 5:03 PM |
|
Hello, I want to perform the following MySQL query:
SELECT {day} as hours
FROM tech_entered_hours
WHERE WEEK('TimeStamp',7) = WEEK('{TimeStamp}',7)
AND user_id = {user_id}
I am trying to set the {day} variable name by pulling the value from a session variable.
Codecharge shows the following code:
$this->ds->Parameters["sesday"] = CCGetSession("day");
$this->wp->AddParameter("2", "sesday", ccsText, "", "", $this->Parameters["sesday"], six, false);
$this->SQL = "SELECT " . $this->SQLValue($this->wp->GetDBValue("2"), ccsText) . " as hours " .
"FROM tech_entered_hours " .
"WHERE WEEK('TimeStamp',7) = WEEK('" . $this->SQLValue($this->wp->GetDBValue("1"), ccsDate) . "',7) " .
"AND user_id = " . $this->SQLValue($this->wp->GetDBValue("3"), ccsInteger) . "";
I have tested the session variable by setting a get session event and it is working correctly and I have also checked the SQL statement to verify that it is pulling the correct records when I manually set the variables.
Any help would be greatly appreciated.
Best Regards,
_________________
Jim |
 |
 |
Nicole
Posts: 586
|
| Posted: 03/04/2005, 2:34 AM |
|
Jim,
I tried to use variables instead of field names too and used the session too. The page works just fine for me.
How exactly a form doesn’t work for you?
Where did you set a session?
And just a note. You’re using a Text type variable, so you need to surround default value "six" with double quotes.
_________________
Regards,
Nicole |
 |
 |
jim7567g
Posts: 38
|
| Posted: 03/04/2005, 1:40 PM |
|
Thanks Nicole, I'll try again.
_________________
Jim |
 |
 |
jim7567g
Posts: 38
|
| Posted: 03/04/2005, 1:42 PM |
|
Oh, I'm setting the session in the before show section of the page, not the grid.
_________________
Jim |
 |
 |
jim7567g
Posts: 38
|
| Posted: 03/04/2005, 2:27 PM |
|
Thank you again for the help, I've figured out what I've done wrong.
In the SQL statement:
WHERE WEEK('TimeStamp',7)
I have quotes around TimeStamp but it should not have them:
WHERE WEEK(TimeStamp,7)
_________________
Jim |
 |
 |
|