Headhunter
|
| Posted: 10/06/2002, 1:39 PM |
|
What is wrong with this query:
ccgetdbvalue("select concat(date_format(now(), '%Y%m%d'),lpad(coalesce(max(substring(serial,9))+1,1), 2,'0')) from pc where substring(serial, 1,8) = date_format(now(), '%Y%m%d')",$dbtrackit)
I know it has something to do with the db connection to be made.
my database is called "trackit"
I get the error "Fatal error: Call to a member function on a non-object in Common.php on line 311"
and line 311 states:
309 function CCGetDBValue($sql, $db)
310 {
311 $db->query($sql);
312 if($db->next_record())
313 return $db->f(0);
314 else
315 return "";
316 }
how should the db connection be established? It's unclear to me.
Thanx
|
|
|
 |
ronb
|
| Posted: 10/07/2002, 6:57 AM |
|
if your connection is called trackit the full name to use is $DBtrackit;
In the event section you myst declare this as global ->
global $gridname;
global $DBconectionname;
//adress the controll you want this informatin used on
$gridname->controlname->setvalue(CCGetDBValue(("select concat(date_format(now(), '%Y%m%d'),lpad(coalesce(max(substring(serial,9))+1,1), 2,'0')) from pc where substring(serial, 1,8) = date_format(now(), '%Y%m%d')",$dbtrackit));
//this is asuming your query will result in 1 value being returned and you want a field in a your grid to show this value
|
|
|
 |
Headhunter
|
| Posted: 10/08/2002, 2:31 AM |
|
OK, I must be stupid.
Where in which event should I declare it? I have put it in the before show event from the textbox, but still no progress.
|
|
|
 |
RonB
|
| Posted: 10/09/2002, 4:37 AM |
|
I'd put it in the grids event. Click on the grid sign and go to before show events.
put the following code in (remember to use your own grid and textbox names)
global $gridname;
global $DBtrackit;
//adress the controll you want this informatin used on
$gridname->textboxname->setvalue(CCGetDBValue(("select concat(date_format(now(), '%Y%m%d'),lpad(coalesce(max(substring(serial,9))+1,1), 2,'0')) from pc where substring(serial, 1,8) = date_format(now(), '%Y%m%d')",$DBtrackit));
Hope this helps
|
|
|
 |
|