If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SELECT within a certain timeframe (timestamp) pre-v4.1?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-05-03, 15:47
invisiblemute invisiblemute is offline
Registered User
 
Join Date: Sep 2003
Posts: 4
SELECT within a certain timeframe (timestamp) pre-v4.1?

I'm trying to write a script to archive the last month's new user registrations that are timestamped which will hopefully be triggered by a cron job.

I'm using PHP and MySQL version 3.23.55 which doesn't support a bunch of useful functions to process date strings like STR_TO_DATE (post v4.1). So I'm wondering how is this done with the older versions? I'm having a really hard time finding documentation. I've done a lot of error checking and I've narrowed it down to the WHERE conditional. It's actually succeeding in creating the file but it's not pulling only the users from the last month. It's pulling all the users.

Thanks in advance.

- - - -

<?php

$now_Y=date("Y");
$now_m=date("m");
$min=date("Ym")."01";
$max=date("Ym")."32";
$start=

$dir="/usr/local/apache/htdocs/SOMEDIR";

$sql="SELECT * INTO OUTFILE "
."'$dir"."users_"."$now_Y"."-"."$now_m".".csv'"
." FIELDS TERMINATED BY ','"
." OPTIONALLY ENCLOSED BY '\"'"
." FROM sn_users"
." WHERE (('$min'<=`created`) <= '$max')";

$res=mysql_query($sql) or die('Error');

?>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On