Flo
|
| Posted: 08/10/2002, 8:20 AM |
|
I maid a database that store dated record (ei: in the date_table1 field) after 30 day i want to make a check procedure that compare between the local date and the date_table1 field (date of record creation). if the result is more than 30 days then i want to update valdid_table1 field from 0 to 1 : - 1 mean that the recor is unvalid - 0 mean it's valide.
for my explenation : table1 is a table from the database, date_table1 & valid_table1 are two field of table1.
Many thank for help in php
Flo...
|
|
|
 |
Nicole
|
| Posted: 08/12/2002, 7:24 AM |
|
Flo,
you should run update query where 'Where' clause contain calculating difference between stored and current date. It is depends on db. Please refer to db help for more information about calculating dates difference or let me know what db do you use.
|
|
|
 |
flo
|
| Posted: 08/13/2002, 2:10 AM |
|
My db is a mysql and i try differente name from the local date but i can't find it
|
|
|
 |
Ron
|
| Posted: 08/13/2002, 2:18 AM |
|
you could put this query in the before show event:
$my_SQL='update bla set blabla=1 where datefield < date_sub(now(),interval 30 DAY)';
$db->query($my_sql);
|
|
|
 |
flo
|
| Posted: 08/13/2002, 7:01 AM |
|
Thank you i will try this this evening !!
|
|
|
 |
flo
|
| Posted: 08/13/2002, 7:01 AM |
|
Thank you i will try this this evening !!
|
|
|
 |
Flo
|
| Posted: 08/17/2002, 8:43 AM |
|
I'm sorry guy but this does not work nothing happen in the database ...
i put your code in the befor show event but nothing !!
nother help ?
|
|
|
 |
RonB
|
| Posted: 08/18/2002, 2:31 AM |
|
Sorry for the incorrect code. Just ment to give you the sql.
Here's the working code(paste in beforeshow event from a grif on the page and substitute table and column names with your own.
global $DBConnection1;
$my_sql='update test set valid=1 where date < date_sub(now(),interval 30 DAY)';
CCGetDBValue($my_sql,$DBConnection1);
Ron
|
|
|
 |
Flo
|
| Posted: 08/20/2002, 5:35 AM |
|
Could you just precise me one or two thing :
i put :
global $DBConnection1;
$my_sql='update test set ACTIVE_EMPLOI=0 where DATEJOUR_EMPLOI < date_sub(now(),interval 20 DAY)';
CCGetDBValue($my_sql,$DBConnection1);
1
Could you tell me what $DBConnection1 mean ? it's the name of my database if not what should i put to get it right.
2
The CCGetDBValue is not reconnize for a function i get this error:
"
Fatal error: Call to undefined function: ccgetdbvalue() in c:\program files\easyphp\www\cs\candid_recherche.php on line 518
"
Many Thank for your help Ron !!!!
What should i do for you ... send me your e-mail i will send you Mountain picture from France : Chamonix Mont-Blanc !
|
|
|
 |
Nicole
|
| Posted: 08/21/2002, 1:57 AM |
|
Flo,
1. $DBConnection1 is the object of the class called clsDBConnection1.
2. please use following code:
global $DBconnection_name;
$my_sql='update test set valid=1 where date < date_sub(now(),interval 30 DAY)';
$DBconnection_name->query($my_sql);
or better open new connection in order not to overwrite the previous query result:
$conn= new clsDBconnection_name;
$my_sql='update test set valid=1 where date < date_sub(now(),interval 30 DAY)';
$conn->query($my_sql);
Do not forget to replace "connection_name" with the real connection name.
|
|
|
 |
Flo
|
| Posted: 08/21/2002, 3:36 AM |
|
Sorry to be stupid but i could i know the name of my connection using a php mysql configuration ?
|
|
|
 |
Nicole
|
| Posted: 08/21/2002, 5:35 AM |
|
Flo,
Look at Project Explorer tree: open Connection node and find connection name.
|
|
|
 |
RonB
|
| Posted: 08/22/2002, 2:54 AM |
|
Nicole,
Thanks nicole for the $conn->query($my_sql); suggestion, I have been looking for a better way for this piece of code myself.
global $DBConnection1;
$my_sql='update test set valid=1 where date < date_sub(now(),interval 30 DAY)';
CCGetDBValue($my_sql,$DBConnection1);
Did work however 
Flo,
Hope you got everything to work now Flo.
France is indeed a beautifull country 
Ron
|
|
|
 |
Gap
|
| Posted: 08/22/2002, 1:08 PM |
|
I think this is a very good question. I can't get the Php/MySQL configuration to work at all. I'm also trying to figure out a connection string. The whole database setup doesn't make sense to me. It would be easier if it just asked for the stuff MySQL has
1) HostName
2) UserName
3) PassWord
4) Database Name
Or had some documentation on this.
|
|
|
 |
gap
|
| Posted: 08/27/2002, 9:40 AM |
|
I think I got the connection working use the MyODBC driver, rather than trying to use an internet connection. Try this. If you have more trouble please feel free to post.
|
|
|
 |