Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
bouncer
Forum Contributor
Posts: 162 Joined: Wed Feb 28, 2007 10:31 am
Post
by bouncer » Thu Aug 07, 2008 12:59 pm
hi there,
how can i set in the @datafield2 the value in $doc_date, so every time that i run the php script it set the date of server.
this is just an example of what i want to do ...
Code: Select all
$doc_date = date('Y-m-d');
LOAD DATA INFILE 'example.csv' REPLACE INTO TABLE `content`
FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY ''
LINES TERMINATED BY '\n'
(`ref`, @datefield1, @datefield2)
SET
`status_date` = STR_TO_DATE(@datefield1, '%d/%m/%Y'),
`doc_date` = ????;
thanks in advance
ghurtado
Forum Contributor
Posts: 334 Joined: Wed Jul 23, 2008 12:19 pm
Post
by ghurtado » Thu Aug 07, 2008 3:18 pm
Could you do something like the following?
Code: Select all
$sql = " ... `status_date` = STR_TO_DATE($doc_date, '%d/%m/%Y') ... ";
bouncer
Forum Contributor
Posts: 162 Joined: Wed Feb 28, 2007 10:31 am
Post
by bouncer » Fri Aug 08, 2008 5:41 am
ghurtado wrote: Could you do something like the following?
Code: Select all
$sql = " ... `status_date` = STR_TO_DATE($doc_date, '%d/%m/%Y') ... ";
no that didn't work
regards
bouncer
Forum Contributor
Posts: 162 Joined: Wed Feb 28, 2007 10:31 am
Post
by bouncer » Fri Aug 08, 2008 6:28 am
i've tried this one and now it work just fine ...
Code: Select all
LOAD DATA INFILE 'example.csv' REPLACE INTO TABLE `content`
FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY ''
LINES TERMINATED BY '\n'
(`ref`, @datefield1)
SET
`status_date` = STR_TO_DATE(@datefield1, '%d/%m/%Y'),
`doc_date` = CURRENT_TIMESTAMP;
regards