Re: [PHP] Re: SQL Syntax

2010-06-17 Thread Ashley Sheridan
On Wed, 2010-06-16 at 15:56 +0200, Carlos Medina wrote:

> Am 16.06.2010 15:50, schrieb Jan Reiter:
> > Richard, Carlos, Simcha and Nigel,
> >
> >
> > Thank you all for your answers on this matter. When I read Simcha's mail, it
> > hit me like a hammer!
> > That was what I was looking for! BUT: I have to see, that this creates way
> > to much overhead, as I have to use  INNER JOIN instead of LEFT JOIN, or an
> > equvalent subquery.
> >
> > I'm currently testing with temporary tables to filter the data before going
> > into the real query.
> >
> > As this is not a real project, just me testing the pros and cons of speed
> > versus flexibility of exactly this table structure, there is no need to
> > restructure the tables.
> >
> > I use 30,000 images as sample data, 7 attributes each.
> >
> > What I have for the images is 3 tables.
> >
> > table picture
> > pid(primary):   the id of the picture
> > uid(index): the user id, to whom the image belongs
> > 
> >
> > table picture_attribute
> > aid(primary):   the id of the attribute
> > name(index):a name for that attribute e.g. fsize
> >
> >
> > table picture_attrib_rel (unique over pid,aid - to avoid the same attribute
> > twice
> > pid(index): the picture, this row belongs to
> > aid(index): the type of attribute this row describes
> > val_int(NULL):  a field for integer values  |
> > val_vc(NULL):   a field for string values   | my class decides
> > wich of these value types to use,
> > the other is NULL
> >
> > My class emulates a foreign_key behavior on aid between picture_attribute
> > and picture_attrib_rel.
> >
> >
> > THANK YOU ALL!!
> >
> > Regards,
> >
> > Jan
> >
> Hi Jan,
> pherhaps because i am working in a projekt with pictures too, but the 
> way i found to solve this was over the same as you are doing now. I took 
> a nm relation with attributes of picture configurations (configuration 
> means width, height, print_material, ink and so one) and add it to the 
> relation on a temp table (only for the search).
> 
> Regards
> 
> Carlos
> 


Hi Jan,

Just thought of something else you could do to avoid data corruption. At
the moment you're using integer values to describe the attribute type.
Whilst this may be fine for your code, I've often found that people like
to edit values in the database directly because it's faster, and you
could end up with issue if they put the wrong values in the wrong
places. I believe MSSQL (which is what I think you said you were using)
has caught up now and has an enum field type which would allow you to
use string values in your queries, but internally they are still stored
as a very small integer (tinyint or the mssql equivalent iirc) which
will save on storage space.

I often do this for database fields (in MySQL) where I know a field will
only ever have a limited range of values, as it sure helps.

This is unless of course the integer value is actually the index of
another table indicating the type, in which case ignore what I said!

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] [OFF] Looking a developer team

2010-06-17 Thread Yuri Yarlei
Greetings,

I look for a developer team to participate theirs projects, and accept a
remote developer. To share knowledge, money, fun, time, beer, etc..

I' ve large experience(8 yr) with PHP OO, PHP structured, Zend Framework,
Drupal, Jquery, css, MySql, SQLServer, PostgreSQL, Oracle, PL/ PGSQL, PLSQL,
JAVA...

ATT,
Yuri Yarlei.
Programmer PHP, JAVA, CSS, ORACLE 10g, PostgreSQL;


Re: [PHP] Unit testing in PHP

2010-06-17 Thread Adam Richardson
>
> From: vikash
>
> > What do you use for unit testing in PHP? phpUnit, SimpleTest or any
> other?
>


SimpleTest because of the flexibility.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] Date Conversion Problem

2010-06-17 Thread Shreyas Agasthya
David,

I think it would help people like me (newbie) to know the exact statements.
Though I could envisage what you would have done with my current learning,
it would be good if I double check the statements that went there to fix
it.

Regards,
Shreyas

On Thu, Jun 17, 2010 at 7:07 PM, David Stoltz  wrote:

> Thanks all - I've fixed the problem.
>
> I fixed it by updating the php statement to write the date in a true SQL
> date-ready format. Then I updated the invalid rows.
>
> Thanks all!
>
>
> -Original Message-
> From: Richard Quadling [mailto:rquadl...@gmail.com]
> Sent: Thursday, June 17, 2010 8:47 AM
> To: David Stoltz
> Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
> Subject: Re: [PHP] Date Conversion Problem
>
> On 17 June 2010 13:40, David Stoltz  wrote:
> > I would agree with you, but I have no control on inherited web apps.
> >
> >
> >
> > I now need to concentrate on trying to fix this.
> >
> >
> >
> > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> > Sent: Thursday, June 17, 2010 8:38 AM
> > To: David Stoltz
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] Date Conversion Problem
> >
> >
> >
> > On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
> >
> >
> > PHP newbie here...
> >
> >
> >
> > I have some PHP code writing the date/time into a MS SQL 2000 database
> > like this:
> >
> >
> >
> > date('l jS \of F Y h:i:s A')
> >
> >
> >
> > So the text it writes into the DB is like: Thursday 15th of April 2010
> > 10:13:42 AM
> >
> >
> >
> > The database field is defined as varchar, not datetime...so it's a
> > string essentially...
> >
> >
> >
> > How in the world do I do a date conversion on this? I've tried things
> > like:
> >
> >
> >
> > select * from table where convert(datetime,fieldname) >= '6/10/2010'
> >
> > (where fieldname is the string in question)
> >
> >
> >
> > Which results in "Syntax error converting datetime from character
> > string."
> >
> >
> >
> > So I guess I have two questions:
> >
> >
> >
> > 1)  Can I write a SQL query that will convert this properly into a
> > datetime?
> >
> > 2)  If not, I guess I'll need to change the code to write the date
> > differently into the system, how should this statement be changed to
> > allow for proper conversion? date('l jS \of F Y h:i:s A')
> >
> >
> >
> > Thanks for any help!
> >
> >
> >
> > It's best to store the date as a date rather than a string, as it avoids
> the sorts of problems you're seeing now.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> >
> >
>
> The "fix" is most likely to be ...
>
> 1 - Convert the string date using PHP's strtotime() function to
> populate a new column on the DB.
> 2 - Find the code that inserts/updates the date string and add the new
> column to the insert/update statement.
>
> That will preserve the current app and allow you to have the new
> column for new work.
>
> Just remember, if _YOU_ update the new column, you must also update
> the original date string also.
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>



-- 
Regards,
Shreyas Agasthya


Re: [PHP] curl help or other suggestion

2010-06-17 Thread Michael Alaimo
As it turns out curl_multi does not block.  I was able to use that plus
connection tracking to solve my problem.

Thanks Ash and Andrew.

Mike

> On Thu, Jun 17, 2010 at 9:05 AM, Michael Alaimo 
> wrote:
>> I am trying to use register_shutdown_function.  Previous to the script
>> shutting down I use curl to grab a website.
>>
>> Basically I want to know if the user has hit the stop button or left the
>> page prematurely.
>>
>> The only problem is that curl runs and finishes its call before the
>> shutdown function is called.  Because of this I  have no way to know
>> if
>> the user canceled the request somehow.  Any suggestions?
>>
>> Mike
>
> I don't know that it will affect cURL, but if you are just looking to
> log completed versus abandoned requests, this might help:
>
> http://www.php.net/manual/en/function.ignore-user-abort.php
>
> Andrew
>
>


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



[PHP] Character Encoding for em-dash

2010-06-17 Thread Gaurav Kumar
Hi All,

My client has a database (Sybase) in which a table column URL contains a
string like-
http://www.pjonline.com/cpd/nutrition_ _drugnutrient_interactions

The box like un-recognized character is emdash.
I need to display the data on the web lets say in a HTML page where box
should be decoded somehow to be displayed as emdash. We cant change anything
in the dataabse as such. So anything we need to do has to be done on the
fly.

I have tried using online tool like http://2cyr.com/decode/ which just
converts the string to a best match decoded string and also displays box as
emdash!!
This means we can do something in PHP to convert the box to emdash somehow.

Is there any possibility in php to convert to real emdash?

I have alreasy tried urldecode, mb_convert_encoding etc. Also the
interesting thing is that "http://2cyr.com/decode/"; website says that the
string is of encoding hp-roman8!

I want the string to look like-
http://www.pjonline.com/cpd/nutrition_--
_prescribing_parenteral_nutrition.html

Any help?

Thanks,

Gaurav Kumar


Re: [PHP] User's IP Validation

2010-06-17 Thread Ashley Sheridan
On Thu, 2010-06-17 at 12:07 -0300, Juan Rodriguez Monti wrote:

> 
> 
> 
> 2010/6/16 Ashley Sheridan 
> 
> 
> On Wed, 2010-06-16 at 20:36 +0200, David Cesal wrote: 
> 
> > Please, don't forget IP address can be same for many users. I see 
> only way with cookies. When user deletes cookies, form pops up again. I don't 
> know any better way.
> > 
> > David
> > 
> > Sent from my HTC
> > 
> > -Original Message-
> > From: Juan Rodriguez Monti 
> > Sent: 16. cervna 2010 20:26
> > To: php-general@lists.php.net
> > Subject: [PHP] User's IP Validation
> > 
> > Hi people,
> > I would like to know the best way to perform some kind of validation
> > for an application that I've written.
> > 
> > I have a system that ask through an HTML Form some questions to 
> users.
> > I use some cookies to save some information from the user side.
> > 
> > However, I would like to implement some code in PHP that would let 
> me
> > limit to 1 the number of times that the page with the questions was
> > executed.
> > 
> > I mean, the user fills the HTML's Form, then send it through an HTML
> > Button, then PHP receives this informations and send an Email
> > containing the replies to the questions. I would like to limit to 
> one,
> > the times one single user is able to execute this form.
> > 
> > I thought getting the IP Address, then doing some kind of validation
> > with it. However I don't know if using cookies is the best idea. I
> > don't have access to a DataBase for this. So I thought might be a 
> good
> > idea write to a file in the server the IP, then perform some if to
> > know if the user already replied the form.
> > 
> > As far as I don't know which is the best way to code this, I felt 
> free
> > to ask you guys.
> > 
> > Thanks a lot.
> > 
> > Juan
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> > 
> > 
> > 
> 
> 
> 
> 
> Like others have said, unless you have specific user logins,
> there's no way to prevent people from viewing the form more
> than once. As you are emailing them the answers, I assume
> there is some form of login system being used, so you could
> use that, with some sort of flag to indicate the email has
> been sent. If you want to future-proof the system, you could
> use some sort of binary bit flag to indicate what forms
> they've been sent answers to, for example:
> 
> 0 - no answers have been sent
> 1 - only the first set of answers
> 4 - the 3rd set of answers only
> 5 - the 3rd and 1st set of answers
> 
> 
> Yes, tha't s true. However I'm not using a DB for this little job.
> 
> There's no login system. There's a little script that runs the form,
> and then send an email to some directions, but not for the user's
> Email address.
> 
> I thought I should use cookies, however is far from secure.
> 
> Thanks a lot people!.
> 
> Juan
> 
> 
> 

What email address are you sending the instructions to then? I had
assumed it was to the person who filled in the form?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] User's IP Validation

2010-06-17 Thread Juan Rodriguez Monti
2010/6/16 Ashley Sheridan 

>  On Wed, 2010-06-16 at 20:36 +0200, David Cesal wrote:
>
> Please, don't forget IP address can be same for many users. I see only way 
> with cookies. When user deletes cookies, form pops up again. I don't know any 
> better way.
>
> David
>
> Sent from my HTC
>
> -Original Message-
> From: Juan Rodriguez Monti 
> Sent: 16. cervna 2010 20:26
> To: php-general@lists.php.net
> Subject: [PHP] User's IP Validation
>
> Hi people,
> I would like to know the best way to perform some kind of validation
> for an application that I've written.
>
> I have a system that ask through an HTML Form some questions to users.
> I use some cookies to save some information from the user side.
>
> However, I would like to implement some code in PHP that would let me
> limit to 1 the number of times that the page with the questions was
> executed.
>
> I mean, the user fills the HTML's Form, then send it through an HTML
> Button, then PHP receives this informations and send an Email
> containing the replies to the questions. I would like to limit to one,
> the times one single user is able to execute this form.
>
> I thought getting the IP Address, then doing some kind of validation
> with it. However I don't know if using cookies is the best idea. I
> don't have access to a DataBase for this. So I thought might be a good
> idea write to a file in the server the IP, then perform some if to
> know if the user already replied the form.
>
> As far as I don't know which is the best way to code this, I felt free
> to ask you guys.
>
> Thanks a lot.
>
> Juan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> Like others have said, unless you have specific user logins, there's no way
> to prevent people from viewing the form more than once. As you are emailing
> them the answers, I assume there is some form of login system being used, so
> you could use that, with some sort of flag to indicate the email has been
> sent. If you want to future-proof the system, you could use some sort of
> binary bit flag to indicate what forms they've been sent answers to, for
> example:
>
> 0 - no answers have been sent
> 1 - only the first set of answers
> 4 - the 3rd set of answers only
> 5 - the 3rd and 1st set of answers
>

Yes, tha't s true. However I'm not using a DB for this little job.

There's no login system. There's a little script that runs the form, and
then send an email to some directions, but not for the user's Email address.

I thought I should use cookies, however is far from secure.

Thanks a lot people!.

Juan


RE: [PHP] Unit testing in PHP

2010-06-17 Thread Bob McConnell
From: vikash

> What do you use for unit testing in PHP? phpUnit, SimpleTest or any
other?

I use Mike Lively's "PHP TAP Test Harness" with test-more.php from the
"Apache Test Harness." This requires a CLI interpreter be installed. I
was already familiar with the equivalent packages in Perl, and this is
mostly a port of them into PHP. In addition to that, I have written my
own db_dummy.php to emulate the PostgreSQL library in PHP.

I have no class, so the OOP test modules are of no use to me. After 40
years of procedural programming, I simply cannot see anything as
objects.

Bob McConnell

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



Re: [PHP] curl help or other suggestion

2010-06-17 Thread Andrew Ballard
On Thu, Jun 17, 2010 at 9:05 AM, Michael Alaimo  wrote:
> I am trying to use register_shutdown_function.  Previous to the script
> shutting down I use curl to grab a website.
>
> Basically I want to know if the user has hit the stop button or left the
> page prematurely.
>
> The only problem is that curl runs and finishes its call before the
> shutdown function is called.  Because of this I  have no way to know if
> the user canceled the request somehow.  Any suggestions?
>
> Mike

I don't know that it will affect cURL, but if you are just looking to
log completed versus abandoned requests, this might help:

http://www.php.net/manual/en/function.ignore-user-abort.php

Andrew

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



Re: [PHP] Unit testing in PHP

2010-06-17 Thread Pavan Keshavamurthy
On Thursday 17 Jun 2010 3:21:18 pm vikash.i...@gmail.com wrote:
> Hi,
> 
> What do you use for unit testing in PHP? phpUnit, SimpleTest or any other?

I tend to prefer SimpleTest.  Mock Objects and the Web UI are IMO, way better 
than what they are with PHPUnit (the last I saw of it). Besides, everything 
comes as a package => much easier to set it up.

As far as CI-tools go, phpUnderControl supports only PHPUnit (out of the box). 
Phing supports both PHPUnit and SimpleTest painlessly.
-- 
Best Regards
Pavan K Murthy
http://grahana.net/


signature.asc
Description: This is a digitally signed message part.


Re: [PHP] curl help or other suggestion

2010-06-17 Thread Ashley Sheridan
On Thu, 2010-06-17 at 09:37 -0400, Michael Alaimo wrote:

> > On Thu, 2010-06-17 at 09:05 -0400, Michael Alaimo wrote:
> >
> >> I am trying to use register_shutdown_function.  Previous to the script
> >> shutting down I use curl to grab a website.
> >>
> >> Basically I want to know if the user has hit the stop button or left the
> >> page prematurely.
> >>
> >> The only problem is that curl runs and finishes its call before the
> >> shutdown function is called.  Because of this I  have no way to know if
> >> the user canceled the request somehow.  Any suggestions?
> >>
> >> Mike
> >>
> >>
> >>
> >
> >
> > You can't. When a visitor closes their browser, or stops the page from
> > completing its loading, no message is sent to the server, so your PHP
> > script won't know about it.
> >
> > The only way I know of currently to check for this is use some form of
> > regular check-in, with Ajax or something, that calls home at regular
> > intervals to inform your script that it is indeed still connected. If it
> > fails to call home in time it either means there's lag on the connection
> > or they broke it.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> 
> 
> I wish that curl would just stop processing.  I think you can use
> connection tracking to know what the user has done.  I just cannot use it
> with my current situation as the code is.
> 
> Mike
> 


If this situation is occurring often, maybe a re-think of the structure
of your app. What is cURL fetching? Is it something that you can cache
at your end, like an RSS feed, etc? If so, maybe use the local cache and
only refresh if the local copy is too old.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] curl help or other suggestion

2010-06-17 Thread Michael Alaimo
> On Thu, 2010-06-17 at 09:05 -0400, Michael Alaimo wrote:
>
>> I am trying to use register_shutdown_function.  Previous to the script
>> shutting down I use curl to grab a website.
>>
>> Basically I want to know if the user has hit the stop button or left the
>> page prematurely.
>>
>> The only problem is that curl runs and finishes its call before the
>> shutdown function is called.  Because of this I  have no way to know if
>> the user canceled the request somehow.  Any suggestions?
>>
>> Mike
>>
>>
>>
>
>
> You can't. When a visitor closes their browser, or stops the page from
> completing its loading, no message is sent to the server, so your PHP
> script won't know about it.
>
> The only way I know of currently to check for this is use some form of
> regular check-in, with Ajax or something, that calls home at regular
> intervals to inform your script that it is indeed still connected. If it
> fails to call home in time it either means there's lag on the connection
> or they broke it.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>


I wish that curl would just stop processing.  I think you can use
connection tracking to know what the user has done.  I just cannot use it
with my current situation as the code is.

Mike


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



RE: [PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
Thanks all - I've fixed the problem.

I fixed it by updating the php statement to write the date in a true SQL 
date-ready format. Then I updated the invalid rows.

Thanks all!


-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Thursday, June 17, 2010 8:47 AM
To: David Stoltz
Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
Subject: Re: [PHP] Date Conversion Problem

On 17 June 2010 13:40, David Stoltz  wrote:
> I would agree with you, but I have no control on inherited web apps.
>
>
>
> I now need to concentrate on trying to fix this.
>
>
>
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, June 17, 2010 8:38 AM
> To: David Stoltz
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Date Conversion Problem
>
>
>
> On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
>
>
> PHP newbie here...
>
>
>
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
>
>
>
> date('l jS \of F Y h:i:s A')
>
>
>
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
>
>
>
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
>
>
>
> How in the world do I do a date conversion on this? I've tried things
> like:
>
>
>
> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>
> (where fieldname is the string in question)
>
>
>
> Which results in "Syntax error converting datetime from character
> string."
>
>
>
> So I guess I have two questions:
>
>
>
> 1)      Can I write a SQL query that will convert this properly into a
> datetime?
>
> 2)      If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
>
>
>
> Thanks for any help!
>
>
>
> It's best to store the date as a date rather than a string, as it avoids the 
> sorts of problems you're seeing now.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
>

The "fix" is most likely to be ...

1 - Convert the string date using PHP's strtotime() function to
populate a new column on the DB.
2 - Find the code that inserts/updates the date string and add the new
column to the insert/update statement.

That will preserve the current app and allow you to have the new
column for new work.

Just remember, if _YOU_ update the new column, you must also update
the original date string also.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


Re: [PHP] curl help or other suggestion

2010-06-17 Thread Ashley Sheridan
On Thu, 2010-06-17 at 09:05 -0400, Michael Alaimo wrote:

> I am trying to use register_shutdown_function.  Previous to the script
> shutting down I use curl to grab a website.
> 
> Basically I want to know if the user has hit the stop button or left the
> page prematurely.
> 
> The only problem is that curl runs and finishes its call before the
> shutdown function is called.  Because of this I  have no way to know if
> the user canceled the request somehow.  Any suggestions?
> 
> Mike
> 
> 
> 


You can't. When a visitor closes their browser, or stops the page from
completing its loading, no message is sent to the server, so your PHP
script won't know about it.

The only way I know of currently to check for this is use some form of
regular check-in, with Ajax or something, that calls home at regular
intervals to inform your script that it is indeed still connected. If it
fails to call home in time it either means there's lag on the connection
or they broke it.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] curl help or other suggestion

2010-06-17 Thread Michael Alaimo
I am trying to use register_shutdown_function.  Previous to the script
shutting down I use curl to grab a website.

Basically I want to know if the user has hit the stop button or left the
page prematurely.

The only problem is that curl runs and finishes its call before the
shutdown function is called.  Because of this I  have no way to know if
the user canceled the request somehow.  Any suggestions?

Mike



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



RE: [PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
Here's my approach to this problem, and how I am planning on fixing this - tell 
me what you think if this will work...

I need the format in the database to be "1/14/2010 3:25:58 PM"

There's not a ton of records that need to be updated, so I was going to:

1) Change the PHP function that is writing the date format incorrectly to the 
above format
2) Then manually go through the records and update the incorrect dates
3) Then change the datatype in the DB for that column from varchar to datetime

Far as I can see, this should work. 

This is why I hate inheriting other people's stuff...not to mention I'm a 
newbie, so that doesn't help ;-)

Thanks!


-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Thursday, June 17, 2010 8:47 AM
To: David Stoltz
Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
Subject: Re: [PHP] Date Conversion Problem

On 17 June 2010 13:40, David Stoltz  wrote:
> I would agree with you, but I have no control on inherited web apps.
>
>
>
> I now need to concentrate on trying to fix this.
>
>
>
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, June 17, 2010 8:38 AM
> To: David Stoltz
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Date Conversion Problem
>
>
>
> On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
>
>
> PHP newbie here...
>
>
>
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
>
>
>
> date('l jS \of F Y h:i:s A')
>
>
>
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
>
>
>
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
>
>
>
> How in the world do I do a date conversion on this? I've tried things
> like:
>
>
>
> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>
> (where fieldname is the string in question)
>
>
>
> Which results in "Syntax error converting datetime from character
> string."
>
>
>
> So I guess I have two questions:
>
>
>
> 1)      Can I write a SQL query that will convert this properly into a
> datetime?
>
> 2)      If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
>
>
>
> Thanks for any help!
>
>
>
> It's best to store the date as a date rather than a string, as it avoids the 
> sorts of problems you're seeing now.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
>

The "fix" is most likely to be ...

1 - Convert the string date using PHP's strtotime() function to
populate a new column on the DB.
2 - Find the code that inserts/updates the date string and add the new
column to the insert/update statement.

That will preserve the current app and allow you to have the new
column for new work.

Just remember, if _YOU_ update the new column, you must also update
the original date string also.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


Re: [PHP] Date Conversion Problem

2010-06-17 Thread Richard Quadling
On 17 June 2010 13:40, David Stoltz  wrote:
> I would agree with you, but I have no control on inherited web apps.
>
>
>
> I now need to concentrate on trying to fix this.
>
>
>
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, June 17, 2010 8:38 AM
> To: David Stoltz
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Date Conversion Problem
>
>
>
> On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
>
>
> PHP newbie here...
>
>
>
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
>
>
>
> date('l jS \of F Y h:i:s A')
>
>
>
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
>
>
>
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
>
>
>
> How in the world do I do a date conversion on this? I've tried things
> like:
>
>
>
> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>
> (where fieldname is the string in question)
>
>
>
> Which results in "Syntax error converting datetime from character
> string."
>
>
>
> So I guess I have two questions:
>
>
>
> 1)      Can I write a SQL query that will convert this properly into a
> datetime?
>
> 2)      If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
>
>
>
> Thanks for any help!
>
>
>
> It's best to store the date as a date rather than a string, as it avoids the 
> sorts of problems you're seeing now.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
>

The "fix" is most likely to be ...

1 - Convert the string date using PHP's strtotime() function to
populate a new column on the DB.
2 - Find the code that inserts/updates the date string and add the new
column to the insert/update statement.

That will preserve the current app and allow you to have the new
column for new work.

Just remember, if _YOU_ update the new column, you must also update
the original date string also.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Date Conversion Problem

2010-06-17 Thread Richard Quadling
On 17 June 2010 13:40, Richard Quadling  wrote:
> On 17 June 2010 13:35, David Stoltz  wrote:
>> PHP newbie here...
>>
>>
>>
>> I have some PHP code writing the date/time into a MS SQL 2000 database
>> like this:
>>
>>
>>
>> date('l jS \of F Y h:i:s A')
>>
>>
>>
>> So the text it writes into the DB is like: Thursday 15th of April 2010
>> 10:13:42 AM
>>
>>
>>
>> The database field is defined as varchar, not datetime...so it's a
>> string essentially...
>>
>>
>>
>> How in the world do I do a date conversion on this? I've tried things
>> like:
>>
>>
>>
>> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>>
>> (where fieldname is the string in question)
>>
>>
>>
>> Which results in "Syntax error converting datetime from character
>> string."
>>
>>
>>
>> So I guess I have two questions:
>>
>>
>>
>> 1)      Can I write a SQL query that will convert this properly into a
>> datetime?
>>
>> 2)      If not, I guess I'll need to change the code to write the date
>> differently into the system, how should this statement be changed to
>> allow for proper conversion? date('l jS \of F Y h:i:s A')
>>
>>
>>
>> Thanks for any help!
>>
>>
>
> Under normal conditions, you would store the date in a datetime
> column. That allows you to do all the date range work in the DB.
>
> When you display the date, you would use PHP's date() function for
> format it appropriately.
>
>
> date('l jS \of F Y h:i:s A', $row['fieldname']);
>
> sort of thing.
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>


Having said that, you will have some serious issues is your dates are
generated from around the world and not purely in your local timezone.

A lack of timezone (Europe/London, Europe/Berlin) rather than the
timezone offset (+1:00, etc.) is the issue here.

Due to DST changes not being consistent worldwide, with the timezones
changing over time, etc. All quite complicated.




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Date Conversion Problem

2010-06-17 Thread Richard Quadling
On 17 June 2010 13:35, David Stoltz  wrote:
> PHP newbie here...
>
>
>
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
>
>
>
> date('l jS \of F Y h:i:s A')
>
>
>
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
>
>
>
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
>
>
>
> How in the world do I do a date conversion on this? I've tried things
> like:
>
>
>
> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>
> (where fieldname is the string in question)
>
>
>
> Which results in "Syntax error converting datetime from character
> string."
>
>
>
> So I guess I have two questions:
>
>
>
> 1)      Can I write a SQL query that will convert this properly into a
> datetime?
>
> 2)      If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
>
>
>
> Thanks for any help!
>
>

Under normal conditions, you would store the date in a datetime
column. That allows you to do all the date range work in the DB.

When you display the date, you would use PHP's date() function for
format it appropriately.


date('l jS \of F Y h:i:s A', $row['fieldname']);

sort of thing.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



RE: [PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
I would agree with you, but I have no control on inherited web apps.

 

I now need to concentrate on trying to fix this.

 

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Thursday, June 17, 2010 8:38 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Date Conversion Problem

 

On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote: 

 
PHP newbie here...
 
 
 
I have some PHP code writing the date/time into a MS SQL 2000 database
like this:
 
 
 
date('l jS \of F Y h:i:s A')
 
 
 
So the text it writes into the DB is like: Thursday 15th of April 2010
10:13:42 AM
 
 
 
The database field is defined as varchar, not datetime...so it's a
string essentially...
 
 
 
How in the world do I do a date conversion on this? I've tried things
like:
 
 
 
select * from table where convert(datetime,fieldname) >= '6/10/2010' 
 
(where fieldname is the string in question)
 
 
 
Which results in "Syntax error converting datetime from character
string."
 
 
 
So I guess I have two questions:
 
 
 
1)  Can I write a SQL query that will convert this properly into a
datetime?
 
2)  If not, I guess I'll need to change the code to write the date
differently into the system, how should this statement be changed to
allow for proper conversion? date('l jS \of F Y h:i:s A')
 
 
 
Thanks for any help!
 


It's best to store the date as a date rather than a string, as it avoids the 
sorts of problems you're seeing now.

Thanks,
Ash
http://www.ashleysheridan.co.uk



 



Re: [PHP] Date Conversion Problem

2010-06-17 Thread Ashley Sheridan
On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:

> PHP newbie here...
> 
>  
> 
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
> 
>  
> 
> date('l jS \of F Y h:i:s A')
> 
>  
> 
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
> 
>  
> 
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
> 
>  
> 
> How in the world do I do a date conversion on this? I've tried things
> like:
> 
>  
> 
> select * from table where convert(datetime,fieldname) >= '6/10/2010' 
> 
> (where fieldname is the string in question)
> 
>  
> 
> Which results in "Syntax error converting datetime from character
> string."
> 
>  
> 
> So I guess I have two questions:
> 
>  
> 
> 1)  Can I write a SQL query that will convert this properly into a
> datetime?
> 
> 2)  If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
> 
>  
> 
> Thanks for any help!
> 


It's best to store the date as a date rather than a string, as it avoids
the sorts of problems you're seeing now.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
PHP newbie here...

 

I have some PHP code writing the date/time into a MS SQL 2000 database
like this:

 

date('l jS \of F Y h:i:s A')

 

So the text it writes into the DB is like: Thursday 15th of April 2010
10:13:42 AM

 

The database field is defined as varchar, not datetime...so it's a
string essentially...

 

How in the world do I do a date conversion on this? I've tried things
like:

 

select * from table where convert(datetime,fieldname) >= '6/10/2010' 

(where fieldname is the string in question)

 

Which results in "Syntax error converting datetime from character
string."

 

So I guess I have two questions:

 

1)  Can I write a SQL query that will convert this properly into a
datetime?

2)  If not, I guess I'll need to change the code to write the date
differently into the system, how should this statement be changed to
allow for proper conversion? date('l jS \of F Y h:i:s A')

 

Thanks for any help!



Re: [PHP] Unit testing in PHP

2010-06-17 Thread Ken Guest
On Thu, Jun 17, 2010 at 10:51 AM,  wrote:

> Hi,
>
> What do you use for unit testing in PHP? phpUnit, SimpleTest or any other?
>
>
Ages ago, when it was new and shiny I did use SimpleTest. Now I mostly use
phpunit - though where necessary (for example if I'm patching a PEAR package
that uses them) I use phpt tests ( http://qa.php.net/write-test.php ).

If you're starting out on something [new] that doesn't yet have unit tests,
I'd suggest phpunit.

hth

Ken


-- 
http://blogs.linux.ie/kenguest/


[PHP] Unit testing in PHP

2010-06-17 Thread vikash . iitb
Hi,

What do you use for unit testing in PHP? phpUnit, SimpleTest or any other?

Thanks,
Vikash Kumar
--
http://vika.sh