php-windows Digest 21 May 2004 12:16:25 -0000 Issue 2256

Topics (messages 23786 through 23791):

Re: Why doesn't php have a 'date' variable type?
        23786 by: Ross Honniball

Re: regular expression  v.s. implode/explode WAS: [PHP-WIN] Passi ng +, =, - at post 
and get
        23787 by: Svensson, B.A.T. (HKG)

Re: Passing +, =, - at post and get
        23788 by: Svensson, B.A.T. (HKG)

Re: IS PHP typless WAS: [PHP-WIN] Why doesn't php have a 'date' v ariable type?
        23789 by: Svensson, B.A.T. (HKG)

updating from xls -> [filter] -> mysql
        23790 by: George Pitcher
        23791 by: Sven Schnitzke

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Thanks Walter and also Justin Patrin for pointing out the Pear Date class.

I just had a quick look and it looks very promising. I still think this sort of thing would be considerably more efficient and accessable to have in native php code in some manner, but it looks like this pear class will certainly help.

Thanks again Walter and Justin.

Regards ... Ross

At 01:29 AM 21/05/2004, you wrote:
PEAR:Date

Walter


"Ross Honniball" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I accidently sent this to php-db mailing list earlier today. Apologies to > people who get it twice. > > Why doesn't php offer a standard class or variable type to help process > dates in a standard manner? > > Php should offer a DATE variable type (in addition to string, int, array, > object etc.). > > Date variables could be created by utilising standard date functions. eg. > > $birthday = SetDate('23-07-1985', 'dmy'); > > Use of this function would effectively declare $birthday as a field of type > date. (note that I wish this was my birthday). > > Standard maths could be performed on date fields for comparison. eg. > > $newdate = $start_date + $birthdate - 5; // as in days > > if ($date1 < $date2) ..whatever..; > > And of course standard routines for formating dates, standard routines for > showing time between dates / times etc. would all understand the date > variable type. > > This frustrated me so much that I recently wrote a class to emulate, as > best as possible, this level of functionality, which would actually be > quite adequate if Windows didn't suck. But due to some lunatic Windows > limitation, the php DATE() funciton will only work on dates between 1970 > and 2038. Annoying. > > Anyway, am I missing something, or do other people find this a glaring > omission in an otherwise spiffing product? > > Ross > > PS note that in refering to dates above, I really mean date + time. > > . Ross Honniball JCU Bookshop Cairns Supervisor > . James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia > . Ph:07.4042.1157 Fx:07.4042.1158 Em:[EMAIL PROTECTED] > . There are no problems. Only solutions.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

. . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. .

--- End Message ---
--- Begin Message ---
Out of curosity: why do you think it would work better or be more direct? 

-----Original Message-----
From: Gryffyn, Trevor
Sent: 20-5-2004 16:50
Subject: RE: [PHP-WIN] Passing +, =, - at post and get

That's gotta be one of the more creative ways around using a regular
expression I've ever seen.. Hah.. Good job Svennson.  A regex or string
replace would probably work better, or at least be more direct though.

-TG

> -----Original Message-----
> From: Svensson, B.A.T. (HKG) 
> Sent: Thursday, May 20, 2004 10:48 AM
> Subject: RE: [PHP-WIN] Passing +, =, - at post and get
> 
[...]
> Also if you just want to replace a single char with another
> single char, then you might like to do like this:
> 
>   $String = implode(explode($String, $OldChar), $NewChar);
>  

--- End Message ---
--- Begin Message ---
Charlers, 

thanks for your comment.

Your suggestion different in the respect that it is better.

(My appiligizes about my ingorance with the PHP API.)

-----Original Message-----
From: Charles P. Killmer
To: [EMAIL PROTECTED]
Sent: 20-5-2004 17:00
Subject: RE: [PHP-WIN] Passing +, =, - at post and get

How is this 
  $String = implode(explode($String, $OldChar), $NewChar);
different than  
  $String = str_replace($OldChar, $NewChar, $String);

Charles Killmer
-----Original Message-----
From: Svensson, B.A.T. (HKG) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 20, 2004 9:48 AM
To: '[EMAIL PROTECTED] '
Subject: RE: [PHP-WIN] Passing +, =, - at post and get

In your second if you do a count on the occurence of a character, but
don't use the result, why not use strpos() directly? 

Also if you just want to replace a single char with another single char,
then you might like to do like this:

  $String = implode(explode($String, $OldChar), $NewChar);



-----Original Message-----
From: George Pitcher
To: [EMAIL PROTECTED]
Sent: 20-5-2004 15:43
Subject: RE: [PHP-WIN] Passing +, =, - at post and get

And doing a bit more, I find that '=' and '-' are passing through OK so
I'll need to train my users to use an alternative to '+'.

The choking seems to be with my parsing function, which I have pasted in
below:
=================================================
function sql_fltr($sql,$field,$input){
        if(strlen($input)>0){
                if( substr_count($input,"=")>0 | substr_count($input,"
-")>0 |
substr_count($input," +")>0 ){
                        $output = "";
                        $temp = str_replace(" -","|-",(str_replace("
-","|-",($input))));
                        $temp = explode("|",$temp);
                        for ($i = 0; $i <= sizeof($temp); $i++){
                                if (substr($temp[$i],0,1)=="*"){
                                        $temp[$i] = $field." like
'".rtrim(str_replace("*","%",$temp[$i]))."%'";
                                        $output.= $temp[$i]."|";
                                } elseif (substr($temp[$i],0,1)=="-"){
                                        $temp[$i] = " and ".$field." not
like
'".rtrim(str_replace("*","%",$temp[$i]))."'";
                                        $output.= $temp[$i]."|";
                                } elseif (substr($temp[$i],0,1)=="="){
                                        $temp[$i] = " and
".$field."='".rtrim(str_replace("=","",$temp[$i]))."'";
                                        $output.= $temp[$i]."|";
                                } elseif (substr($temp[$i],0,1)!="+" &&
substr($temp[$i],0,1)!="-"&&substr($temp[$i],0,1)!="*" &&
substr($temp[$i],0,1)!="="){
                                        $temp[$i] = "and ".$field." like
'%".rtrim(str_replace("=","",$temp[$i]))."'";
                                        $output.= $temp[$i]."|";
                                } else {
                                        $temp[$i] = "
".$field."='".rtrim($temp[$i])."'";
                                        $output.= $temp[$i]."|";
                                }
                        }
                        $output = " AND
".substr($output,0,strlen($output)-1);
                } else {
                        $temp = $input;
                        if (substr($temp,0,1)=="*"){
                                $temp = $field." like
'".rtrim(str_replace("*","%",$temp))."'";
                        } elseif (substr($temp,0,1)=="-"){
                                $temp = $field." not like
'".rtrim(str_replace("*","%",$temp))."'";
                        } elseif (substr($temp,0,1)=="="){
                                $temp =
$field."='".rtrim(str_replace("=","",$temp))."'";
                        } elseif (substr($temp,0,1)!="+" &&
substr($temp,0,1)!="-"&&substr($temp,0,1)!="*" &&
substr($temp,0,1)!="="){
                                $temp = $field." like
'%".rtrim(str_replace("=","",$temp))."'";
                        } else {
                                $temp = $field."='".rtrim($temp)."'";
                        }
                        $output = " AND ".$temp;
                }
        } else {
                $output = "";
        }
        return $output;
}
=================================================
This works fine if the user has eneterd either no control or the *
wildcared with the criteria.

Any suggestions?

Cheers

George


> -----Original Message-----
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: 20 May 2004 2:33 pm
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-WIN] Passing +, =, - at post and get
>
>
> Charles,
>
> No way! This site will only have about 3-4 users as its an intranet 
> and I'll be parsing everything at the server end.
>
> George
>
>
> > -----Original Message-----
> > From: Charles P. Killmer [mailto:[EMAIL PROTECTED]
> > Sent: 20 May 2004 2:31 pm
> > To: [EMAIL PROTECTED]
> > Subject: RE: [PHP-WIN] Passing +, =, - at post and get
> >
> >
> >  I hope you are not allowing the client to send T-SQL through the
query
> > string.  Consider them sending something like File.php?Query='; drop

> > table XXX; --
> >
> > Charles Killmer
> >
> > -----Original Message-----
> > From: George Pitcher [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, May 20, 2004 8:25 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-WIN] Passing +, =, - at post and get
> >
> > Hi,
> >
> > I want to be able to pass the '=', '+' and '-' characters both from
a
> > web form and as part of a url, to enable a better way of searching.
> > However, these characters are choking my IIS webserver and not
getting
> > through to the script.
> >
> > Can anyone suggest a better way of achieving this?
> >
> > Cheers
> >
> > George
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/) To unsubscribe,
visit:
> > http://www.php.net/unsub.php
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/) To unsubscribe, 
> > visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
OK, OK, PHP is weakly typed. Happy now? ;) :) 

-----Original Message-----
From: Ross Honniball
Sent: 21-5-2004 1:57
Subject: RE: [PHP-WIN] Why doesn't php have a 'date' variable type?

php isn't typeless. 

--- End Message ---
--- Begin Message ---
Hi,

I'm thinking ahead to something I'll need to tackle in the future.

My current system is Filemaker based and I can import straight from Excel
spreadsheets - but with no checking available. Now that I'm re-writing into
php/mysql(pear:dB)/smarty, If I can, I'd like the user to be able to select
the file (I can do that bit), check that the column positions match a
predefined format (?), and then update records in my db table.

Does this look doable? Any hints on how? I don't want to use ODBC as the
filename will be constantly changing so there'll be no dsn set up.

George in Oxford


--- End Message ---
--- Begin Message ---
Hi George,
are you familiar with COM? If so, consider:

// select range to $r , then do
if($r->NumberFormat()="a format") { ... }

where "a format" can be "Standard" or something like
"#,##0.00; -###0.00" or so as used in the "Format - Cells"
dialog of Excel.

With Excel 8 there seems to be a glitch as it returns localized
colour names and does not accept english ones (At least my German
version behaves this way; didn't scrutinize too deeply though).

If you are interested I will send you a basic PHP COM script
doing EXCEL I/O to start from.

HTH
-- 
Sven Schnitzke


> -----Urspr�ngliche Nachricht-----
> Von:  George Pitcher [SMTP:[EMAIL PROTECTED]
> Gesendet am:  Freitag, 21. Mai 2004 12:08
> An:   [EMAIL PROTECTED]
> Betreff:      [PHP-WIN] updating from xls -> [filter] -> mysql
> 
> Hi,
> 
> I'm thinking ahead to something I'll need to tackle in the future.
> 
> My current system is Filemaker based and I can import straight from Excel
> spreadsheets - but with no checking available. Now that I'm re-writing into
> php/mysql(pear:dB)/smarty, If I can, I'd like the user to be able to select
> the file (I can do that bit), check that the column positions match a
> predefined format (?), and then update records in my db table.
> 
> Does this look doable? Any hints on how? I don't want to use ODBC as the
> filename will be constantly changing so there'll be no dsn set up.
> 
> George in Oxford
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---

Reply via email to