Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 16: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

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