Re: [PHP] php5-fpm segfault

2011-09-30 Thread Laruence
Hi  :
   could you file a bug at https://bugs.php.net/

   this is the proper way to report a bug  :)

thanks

-- 
Laruence  Xinchen Hui
http://www.laruence.com/

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



Re: [PHP] php5-fpm segfault

2011-09-30 Thread Александр Гончаров
You think this is PHP's bug? I'm not sure. Because PHP installed not
latest version and yesterday i tune memory_limit setting to 256M (was
-1) and no segfaults registered since that moment. I think, bad
designed script allocate too much memory and php-fpm worker become mad
and kill himself. But it's hard to find the culprit in a huge number
of scripts.

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



Re: [PHP] PHP5 cgi Suexec htaccess rewrite issue

2011-09-29 Thread Tommy Pham
On Thu, Sep 29, 2011 at 5:43 AM, Shaun Morrow morrow.sh...@gmail.comwrote:

 I am running a server with cPanel  on and want to have php run as a cgi
 with
 Suexec enabled

 I cannot seem to rectify an issue, when I set the handler to cgi, my
 rewrite
 rules on one of my sites stop working

 Sample url: http://examplesite.com/ad/123-abcde/

 The rewrite rule for this is below;


 RewriteEngine on
 RewriteBase /

 RewriteRule ^ad/([0-9]+)(.*)$
 ./index.php/ads/ads/action/viewAd/frmAdsID/$1/adTitle/$2 [L]


 Currently the php 5 handler is dso, and the rewrite rule works perfectly.

 If the handler is set to cgi, the rewrite rule does not work and I the site
 just displays the home page.

 I am at a loss and would appreciate some help.

 Thanks in advance!


Did you make the changes accordingly in php.ini?  I recall that cgi/fastcgi
requires different configuration than from isapi type - dll/dso.  I don't
know how httpd handles impersonation on *nix platform as I've never had to
configure it that way.  Here's a few from the php.ini

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
; http://php.net/doc-root

; cgi.force_redirect is necessary to provide security running PHP as a CGI
under
; most web servers.  Left undefined, PHP turns this on by default.  You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; http://php.net/cgi.force-redirect

; if cgi.nph is enabled it will force cgi to always sent Status: 200 with
; every request. PHP's default behavior is to disable this feature.

; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for
CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to
not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.
Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A
setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix
your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo

; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
; security tokens of the calling client.  This allows IIS to define the
; security context that the request runs under.  mod_fastcgi under Apache
; does not currently support this feature (03/17/2002)
; Set to 1 if running under IIS.  Default is zero.
; http://php.net/fastcgi.impersonate

Note that the above is from old config file and is configured for PHP to run
as FastCGI on IIS7.5.  There maybe recent changes regarding httpd and
impersonation.

Go through the php.ini and make all relevant changes regarding 'cgi'.

Regards,
Tommy


Re: [PHP] php5 - website development - what next

2010-10-08 Thread Daniel P. Brown
On Fri, Oct 8, 2010 at 09:53, Rakesh Mishra rakesh.mis...@gmail.com wrote:

 Even I believe my knowledge, interest,  market value  with PHP 5 is getting
 saturated.
 Do you guys suggest me what other thing I can learn or work which help me to
 keep my lust for PHP alive
 and also boost my career.

Write desktop applications: http://gtk.php.net/ .

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP] php5 - website development - what next

2010-10-08 Thread 惠新宸


On 10/08/2010 22:06, 惠新宸 wrote:

test,
i can't send mail to lists?

thanks
On 10/08/2010 22:02, 惠新宸 wrote:

Hi:
   1. you can be a Software Architect
2. you can abstract common requirements, developed php extension.

thanks.


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



Re: [PHP] php5 - website development - what next

2010-10-08 Thread Paul M Foster
On Fri, Oct 08, 2010 at 07:23:59PM +0530, Rakesh Mishra wrote:

 Hi All,
 
 I  am PHP 4  PHP 5 developer for last 6 yrs. Last year  also got Zend
 certification.
 Since now I have work on different CMS, Social Networking, telecome , horse
 racing domains.
 
 But now I am little bored with developing website. What other things I can
 do with PHP ?
 
 Even I believe my knowledge, interest,  market value  with PHP 5 is getting
 saturated.
 Do you guys suggest me what other thing I can learn or work which help me to
 keep my lust for PHP alive
 and also boost my career.

There are a variety of major projects which use PHP as their primary
language. Like WordPress. See freshmeat.net and sourceforge.net for
projects written in PHP. You could contribute to these projects, and
increase your knowledge and prestige.

Paul

-- 
Paul M. Foster

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



Re: [PHP] php5 - website development - what next

2010-10-08 Thread Richard Quadling
On 8 October 2010 14:53, Rakesh Mishra rakesh.mis...@gmail.com wrote:
 Hi All,

 I  am PHP 4  PHP 5 developer for last 6 yrs. Last year  also got Zend
 certification.
 Since now I have work on different CMS, Social Networking, telecome , horse
 racing domains.

 But now I am little bored with developing website. What other things I can
 do with PHP ?

 Even I believe my knowledge, interest,  market value  with PHP 5 is getting
 saturated.
 Do you guys suggest me what other thing I can learn or work which help me to
 keep my lust for PHP alive
 and also boost my career.

 Regards
 Rakesh


I'm building Windows Services (not Web Services) with PHP and an
enhanced pecl/win32service extension, in conjunction with
WScript.Shell to simulate threading and and WinCache for
inter-processing comms.

OK. It is a daft thing to do. But it is working and is replacing a
bunch of console apps written in .BAT with some .EXEs. The SysOps are
happier as it is just a normal windows services (so they can
stop/start/pause it). Shutdown/bootup server - all OK.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RE: [PHP] PHP5 SOAP...

2009-06-16 Thread bruce
hi russell...

isn't the actual soap data/packet that's being sent over the wire viewable
via an app like livehttpheaders... (at least from firefox)

or are you looking for something in much more detail...



-Original Message-
From: rjon...@gmail.com [mailto:rjon...@gmail.com]on Behalf Of Russell
Jones
Sent: Tuesday, June 16, 2009 8:22 AM
To: PHP General
Subject: [PHP] PHP5 SOAP...


I'm working on a project using SOAP and WS-Security in which I am failing
miserably.

Is there a way to inspect the actual XML, header, etc. that is actually
being sent. I feel like I am constructing the call correctly, and I know
exactly what needs to be sent, but I dont know how to see exactly what is
sent - all I get back are useless errors like not enough information sent,
etc...

Any ideas? Any SOAP pros out there?


Russell Jones
CTO Virante, Inc.
r...@virante.com
919-459-1035


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



Re: [PHP] PHP5 SOAP...

2009-06-16 Thread Tom Rogers
Hi,

Wednesday, June 17, 2009, 1:21:47 AM, you wrote:
RJ I'm working on a project using SOAP and WS-Security in which I am failing
RJ miserably.

RJ Is there a way to inspect the actual XML, header, etc. that is actually
RJ being sent. I feel like I am constructing the call correctly, and I know
RJ exactly what needs to be sent, but I dont know how to see exactly what is
RJ sent - all I get back are useless errors like not enough information sent,
RJ etc...

RJ Any ideas? Any SOAP pros out there?


RJ Russell Jones
RJ CTO Virante, Inc.
RJ r...@virante.com
RJ 919-459-1035

Not a pro but...
Try something like this:
//object to pass function variables
class requestObject {
function requestObject($list) {
foreach($list as $key=$val)
$this-$key = $val;
}
}

$client = new  SoapClient(wsdl.xml, array('login'= login, 'password'= 
password, 'trace'=true));

$soapstruct = new requestObject(array('clientId'=12342, 'leagueId'=0)); //use 
whatever variables are needed
try {
$info = $client-soapFunction($soapstruct);
echo REQUEST:\n . $client-__getLastRequest() . br /\n;
print_r($info);
} catch (SoapFault $e) {
echo SOAP Fault: .$e-getMessage().br /\n;
echo REQUEST:\n . $client-__getLastRequest() . br /\n;
}

-- 
regards,
Tom


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



Re: [PHP] php5-mhash disabled...

2009-04-02 Thread Chris

Anders Norrbring wrote:

I just saw that mhash is disabled in the spec file for php5 if SUSE version
is 11.0 or higher.
Simple question, does it do any harm?


If they decided to do that it's best to ask suse (or on the opensuse 
lists if you're using that flavour).


It may just be because it's deprecated but it could be for some other 
reason (eg binary compatibility issues or licensing issues or .. ).


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nick Stinemates
On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote:
 Hello!

 Seems that PHP gets more and more object oriented, which is good.

 I am now running a course in PHP, using PHP 5, where we are going to
 use the *DOM* interface. I am trying to teach them good OO practices,
 meaning that we insistently hide properties and expose them as get or
 set methods.

Get/set methods are more often than not breaking encapsulation and
should be avoided (unless purposefully designing Model object or
something similar.)



 Looking at the PHPs *DOM* implementation, I see that many of the
 properties are exposed directly, without even offering get methods.

Can you please provide an example of where this is happening?


 1. Is there something I am misunderstanding orotherwise missing? (I
 havenot used *DOM* in PHP before).

 2.This poses a pedagogical problem for me as a teacher. How do I
 explain this contradiction to my students?

Explain that the DOM API and PHP's binding to the DOM API are 2
different things with 2 different goals.


 Thanks

 Michael

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



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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED]
wrote:

 On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote:
  Hello!
 
  Seems that PHP gets more and more object oriented, which is good.
 
  I am now running a course in PHP, using PHP 5, where we are going to
  use the *DOM* interface. I am trying to teach them good OO practices,
  meaning that we insistently hide properties and expose them as get or
  set methods.

 Get/set methods are more often than not breaking encapsulation and
 should be avoided (unless purposefully designing Model object or
 something similar.)


egh?  we had a massive argument about this last year, but if u ask me data
hiding is an integral part of encapsulation; therefore i agree w/ Michael.


 Looking at the PHPs *DOM* implementation, I see that many of the
 properties are exposed directly, without even offering get methods.

so, if its a big deal, write a proxy(s) which adds the encapsulation (as u
see it) u need.

Can you please provide an example of where this is happening?


heres a list of em from DomDocument,
readonly public string
$actualEncodinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.actualencoding;
 readonly public DOMConfiguration
$confighttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.config;
 readonly public
DOMDocumentTypehttp://us2.php.net/manual/en/class.domdocumenttype.php
$doctypehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.doctype;
 readonly public DOMElementhttp://us2.php.net/manual/en/class.domelement.php
$documentElementhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.documentelement;
 public string 
$documentURIhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.documenturi;
 public string 
$encodinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.encoding;
 public bool 
$formatOutputhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.formatoutput;
 readonly public
DOMImplementationhttp://us2.php.net/manual/en/class.domimplementation.php
$implementationhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.implementation;
 public bool 
$preserveWhiteSpacehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.preservewhitespace
=true ;
 public bool 
$recoverhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.recover;
 public bool 
$resolveExternalshttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.resolveexternals;
 public bool 
$standalonehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.standalone;
 public bool 
$strictErrorCheckinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.stricterrorchecking
=true ;
 public bool 
$substituteEntitieshttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.substituteentities;
 public bool 
$validateOnParsehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.validateonparse
=false ;
 public string 
$versionhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.version;
 readonly public string
$xmlEncodinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.xmlencoding;
 public bool 
$xmlStandalonehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.xmlstandalone;
 public string 
$xmlVersionhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.xmlversion;


 1. Is there something I am misunderstanding orotherwise missing? (I
 havenot used *DOM* in PHP before).

have you looked at SimpleXMLElement / SimpleXMLIterator ??  i find it to be
one of those 80% / 20% relationships where simplexml takes care of the needs
most of the time (and saves your poor brain from smoking).

 2.This poses a pedagogical problem for me as a teacher. How do I
 explain this contradiction to my students?

the world doest operate 'by-the-book'  thats life.  i was a teacher once
(just for a semester) but i was teaching oop.  at the end of the day who
knows why they did it that way.  perhaps their views are different than
yours or the book from which your teaching.  explain to them that there are
options, such as building a proxy, but there will be consequences in terms
of performance and increased complexity.

-nathan


Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nick Stinemates
On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote:
 On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED]
 wrote:
 
  On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote:
   Hello!
  
   Seems that PHP gets more and more object oriented, which is good.
  
   I am now running a course in PHP, using PHP 5, where we are going to
   use the *DOM* interface. I am trying to teach them good OO practices,
   meaning that we insistently hide properties and expose them as get or
   set methods.
 
  Get/set methods are more often than not breaking encapsulation and
  should be avoided (unless purposefully designing Model object or
  something similar.)
 
 
 egh?  we had a massive argument about this last year, but if u ask me data
 hiding is an integral part of encapsulation; therefore i agree w/ Michael.
 

Data Hiding IS Encapsulation.

But, you have to agree,

?php

class Lol {
 private $bar;

 public function getBar() { return $bar }
 public function setBar($bar) { $this-bar = $bar}

}
?

Is no different than:

?php
class Lol {
 public $bar;
}
?


Here's a more thought out argument from 
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html :

 A fundamental precept of OO systems is that an object should not expose any 
 of its implementation details. This way, you can change the implementation 
 without changing the code that uses the object. It follows then that in OO 
 systems you should avoid getter and setter functions since they mostly 
 provide access to implementation details.

 To see why, consider that there might be 1,000 calls to a getX() method in 
 your program, and each call assumes that the return value is of a particular 
 type. You might store getX()'s return value in a local variable, for example, 
 and that variable type must match the return-value type. If you need to 
 change the way the object is implemented in such a way that the type of X 
 changes, you're in deep trouble. 

-- 
Nick Stinemates ([EMAIL PROTECTED])
http://nick.stinemates.org

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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Jim Lucas

Nick Stinemates wrote:

On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote:

On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED]
wrote:


On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote:

Hello!

Seems that PHP gets more and more object oriented, which is good.

I am now running a course in PHP, using PHP 5, where we are going to
use the *DOM* interface. I am trying to teach them good OO practices,
meaning that we insistently hide properties and expose them as get or
set methods.

Get/set methods are more often than not breaking encapsulation and
should be avoided (unless purposefully designing Model object or
something similar.)


egh?  we had a massive argument about this last year, but if u ask me data
hiding is an integral part of encapsulation; therefore i agree w/ Michael.



Data Hiding IS Encapsulation.

But, you have to agree,

?php

class Lol {
 private $bar;

 public function getBar() { return $bar }
 public function setBar($bar) { $this-bar = $bar}

}
?

Is no different than:

?php
class Lol {
 public $bar;
}
?


Here's a more thought out argument from 
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html :


A fundamental precept of OO systems is that an object should not expose any of 
its implementation details. This way, you can change the implementation without 
changing the code that uses the object. It follows then that in OO systems you 
should avoid getter and setter functions since they mostly provide access to 
implementation details.

To see why, consider that there might be 1,000 calls to a getX() method in your program, and each call assumes that the return value is of a particular type. You might store getX()'s return value in a local variable, for example, and that variable type must match the return-value type. If you need to change the way the object is implemented in such a way that the type of X changes, you're in deep trouble. 




No,but in the first one, you can control, from within the class/method, what 
data is actually allowed to be injected into that variable.  Whereas the second 
example would allow you to stuff any type of data into that class variable. 
That might not be a good thing.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nick Stinemates
 Data Hiding IS Encapsulation.
 But, you have to agree,
 ?php
 class Lol {
  private $bar;
  public function getBar() { return $bar }
  public function setBar($bar) { $this-bar = $bar}
 }
 ?
 Is no different than:
 ?php
 class Lol {
  public $bar;
 }
 ?
 Here's a more thought out argument from 
 http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html :
 A fundamental precept of OO systems is that an object should not expose 
 any of its implementation details. This way, you can change the 
 implementation without changing the code that uses the object. It follows 
 then that in OO systems you should avoid getter and setter functions 
 since they mostly provide access to implementation details.

 To see why, consider that there might be 1,000 calls to a getX() method 
 in your program, and each call assumes that the return value is of a 
 particular type. You might store getX()'s return value in a local 
 variable, for example, and that variable type must match the return-value 
 type. If you need to change the way the object is implemented in such a 
 way that the type of X changes, you're in deep trouble. 

 No,but in the first one, you can control, from within the class/method, 
 what data is actually allowed to be injected into that variable.  Whereas 
 the second example would allow you to stuff any type of data into that 
 class variable. That might not be a good thing.


That's a relatively narrow minded response to my point, since I gave
a pretty concrete example of exactly what I meant, followed by a great
article which furthered my point.

The general rule of encapsulation is: Don't ask an object for data, ask
the object to work with the data.

-- 
Nick Stinemates ([EMAIL PROTECTED])
http://nick.stinemates.org

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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Fri, Apr 18, 2008 at 11:21 AM, Nick Stinemates [EMAIL PROTECTED]
wrote:

 On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote:
  On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED]
  wrote:
 
   On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote:
Hello!
   
Seems that PHP gets more and more object oriented, which is good.
   
I am now running a course in PHP, using PHP 5, where we are going to
use the *DOM* interface. I am trying to teach them good OO
 practices,
meaning that we insistently hide properties and expose them as get
 or
set methods.
  
   Get/set methods are more often than not breaking encapsulation and
   should be avoided (unless purposefully designing Model object or
   something similar.)
  
 
  egh?  we had a massive argument about this last year, but if u ask me
 data
  hiding is an integral part of encapsulation; therefore i agree w/
 Michael.
 

 Data Hiding IS Encapsulation.

 But, you have to agree,

 ?php

 class Lol {
  private $bar;

  public function getBar() { return $bar }
  public function setBar($bar) { $this-bar = $bar}

 }
 ?

 Is no different than:

 ?php
 class Lol {
  public $bar;
 }
 ?


it is different, by your very definition.  quote 'Data Hiding IS
Encapsulation'  so the difference in the 2 examples you supplied is that the
first one is an example of encapsulation, whereas the later is not.
encapsulation provides control.  it reduces the possibility of client code
binding to implementation details which decreases coupling.  go into the
archives, you will find the argument from last year.  its in the same one
about interfaces, that we pretty much re-hashed this week.

-nathan


Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Fri, Apr 18, 2008 at 11:50 AM, Nick Stinemates [EMAIL PROTECTED]
wrote:

 That's a relatively narrow minded response to my point, since I gave
 a pretty concrete example of exactly what I meant,


no, its a very valid criticism of your flawed example.  you supply a
definition of encapsulation, and then demonstrate, by example, that you dont
understand its importance.


 followed by a great
 article which furthered my point.


take a look at the books i listed in the argument last year.  youll find
that all the books ive ever read on oop are strong proponents of data-hiding
as a component of encapsulation.

The general rule of encapsulation is: Don't ask an object for data, ask
 the object to work with the data.


more precisely, operations on a class should be driven through a
well-defined public interface.

-nathan


Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Jim Lucas

Nick Stinemates wrote:

Data Hiding IS Encapsulation.
But, you have to agree,
?php
class Lol {
 private $bar;
 public function getBar() { return $bar }
 public function setBar($bar) { $this-bar = $bar}
}
?
Is no different than:
?php
class Lol {
 public $bar;
}
?
Here's a more thought out argument from 
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html :
A fundamental precept of OO systems is that an object should not expose 
any of its implementation details. This way, you can change the 
implementation without changing the code that uses the object. It follows 
then that in OO systems you should avoid getter and setter functions 
since they mostly provide access to implementation details.


To see why, consider that there might be 1,000 calls to a getX() method 
in your program, and each call assumes that the return value is of a 
particular type. You might store getX()'s return value in a local 
variable, for example, and that variable type must match the return-value 
type. If you need to change the way the object is implemented in such a 
way that the type of X changes, you're in deep trouble. 
No,but in the first one, you can control, from within the class/method, 
what data is actually allowed to be injected into that variable.  Whereas 
the second example would allow you to stuff any type of data into that 
class variable. That might not be a good thing.




That's a relatively narrow minded response to my point, since I gave
a pretty concrete example of exactly what I meant, followed by a great
article which furthered my point.



Let me quote, you said this: Is no different than  You are wrong, in fact it 
IS different.  Having your own custom methods to get or set data allows you to 
have more control over what data is injected into your object.


I would call is a personal preference which may not work for you, but works fine 
for me.


All I can say is that all my __set methods do data sanitizing and validation, 
which is were I think it should be done.  If anybody thinks this might be a bad 
thing, please by all means explain why it is bad.




The general rule of encapsulation is: Don't ask an object for data, ask
the object to work with the data.



I hope it checks the data first before using it.  If you don't then you might 
end up with something you had not planned on.


If I am not to ask an object for data how is my db class/object ever going to 
return me data from my database?


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Robert Cummings

On Fri, 2008-04-18 at 11:50 -0700, Jim Lucas wrote:
 Nick Stinemates wrote:
  Data Hiding IS Encapsulation.
  But, you have to agree,
  ?php
  class Lol {
   private $bar;
   public function getBar() { return $bar }
   public function setBar($bar) { $this-bar = $bar}
  }
  ?
  Is no different than:
  ?php
  class Lol {
   public $bar;
  }
  ?
  Here's a more thought out argument from 
  http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html :
  A fundamental precept of OO systems is that an object should not expose 
  any of its implementation details. This way, you can change the 
  implementation without changing the code that uses the object. It 
  follows 
  then that in OO systems you should avoid getter and setter functions 
  since they mostly provide access to implementation details.
 
  To see why, consider that there might be 1,000 calls to a getX() method 
  in your program, and each call assumes that the return value is of a 
  particular type. You might store getX()'s return value in a local 
  variable, for example, and that variable type must match the 
  return-value 
  type. If you need to change the way the object is implemented in such a 
  way that the type of X changes, you're in deep trouble. 
  No,but in the first one, you can control, from within the class/method, 
  what data is actually allowed to be injected into that variable.  Whereas 
  the second example would allow you to stuff any type of data into that 
  class variable. That might not be a good thing.
 
  
  That's a relatively narrow minded response to my point, since I gave
  a pretty concrete example of exactly what I meant, followed by a great
  article which furthered my point.
  
 
 Let me quote, you said this: Is no different than  You are wrong, in fact 
 it 
 IS different.  Having your own custom methods to get or set data allows you 
 to 
 have more control over what data is injected into your object.
 
 I would call is a personal preference which may not work for you, but works 
 fine 
 for me.
 
 All I can say is that all my __set methods do data sanitizing and validation, 
 which is were I think it should be done.  If anybody thinks this might be a 
 bad 
 thing, please by all means explain why it is bad.
 
 
  The general rule of encapsulation is: Don't ask an object for data, ask
  the object to work with the data.
  
 
 I hope it checks the data first before using it.  If you don't then you might 
 end up with something you had not planned on.
 
 If I am not to ask an object for data how is my db class/object ever going to 
 return me data from my database?

What he means is don't ask for the data literally (by property name) ask
for it via a method. This allows wrapping the data in work. This is a
moot issue in PHP since PHP allows trapping the property accessor.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Fri, Apr 18, 2008 at 12:50 PM, Jim Lucas [EMAIL PROTECTED] wrote:


 Let me quote, you said this: Is no different than  You are wrong, in
 fact it IS different.  Having your own custom methods to get or set data
 allows you to have more control over what data is injected into your object.


lol.  wait a second, jim, you think a class w/ 2 methods isnt the same as
one w/ no methods :O

I would call is a personal preference which may not work for you, but works
 fine for me.


strangely enough, last year when we argued, it became clear the definition
of encapsulation varies quite a bit across the people who subscribe to this
list, tho i posted 4 examples from texts ive read over the years that all
essentialY incorporate data hiding into the definition of encapsulation.

All I can say is that all my __set methods do data sanitizing and
 validation, which is were I think it should be done.  If anybody thinks this
 might be a bad thing, please by all means explain why it is bad.


right; 100%.  and even if setters are as simple as

function setStuff($stuff) {  $this-stuff = $stuff; }

the client is still being driven through a well defined public interface,
which supports the ability to add validation logic later on w/o impacting
client code.  you could also change the internal variable from $stuff to
$goofy and it would be transparent to the client.  the point here is
indirection, which in programming terms is basically synonymous w/
flexibility.  yes there are costs, runtime performance, system complexity,
but these are the tradeoffs for flexibility.  when you take it to a higher
level thats what design patterns are all about.  standardized techniques to
incorporate flexibility into an application.

-nathan


Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Fri, Apr 18, 2008 at 1:02 PM, Robert Cummings [EMAIL PROTECTED]
wrote:

 What he means is don't ask for the data literally (by property name) ask
 for it via a method. This allows wrapping the data in work. This is a
 moot issue in PHP since PHP allows trapping the property accessor.


i dont think its moot.  if your trapping it via __get() or __set() its still
the same action; driving the client through a well defined interface; if it
just happens to have the same name as the property itself, its still the
same concept.  you have the 'work' in the magic methods (at a minimum the
initial part), instead of the getters and setters you would build yourself.
and personally, i think it much cleaner to have separate methods for each of
the properties rather than one big function which has to internally route
control via some sort of logic, be it conditional, variable functions or
w/e.
besides which, for the magic methods to work, the variables have to be
'inaccessible' according to the docs which means protected, private, or
non-existent; and barring the case of non-existent we are right back in the
realm of encapsulation.
unless you meant something different by 'trapping the property accessor';
which you usually do pull some unexpected stuff so im waiting for your next
clever example to prove me wrong :D


nathan-nobbes-macbook-pro:~ nnobbe$ cat testSet.php
?php

class A {
public $blah;
protected $meh;
private $dude;

function __get($var) {
echo __METHOD__ . PHP_EOL;
}

function __set($var, $val) {
echo __METHOD__ .  var: $var  . PHP_EOL;
}
}

$a = new A();
$a-blah = 5;
$a-meh = 6;
$a-dude = 7;
$a-fake = 8;

?

nathan-nobbes-macbook-pro:~ nnobbe$ php testSet.php
A::__set var: meh
A::__set var: dude
A::__set var: fake

-nathan


Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Robert Cummings

On Fri, 2008-04-18 at 13:17 -0600, Nathan Nobbe wrote:
 On Fri, Apr 18, 2008 at 1:02 PM, Robert Cummings [EMAIL PROTECTED]
 wrote:
 
  What he means is don't ask for the data literally (by property name) ask
  for it via a method. This allows wrapping the data in work. This is a
  moot issue in PHP since PHP allows trapping the property accessor.
 
 
 i dont think its moot.  if your trapping it via __get() or __set() its still
 the same action; driving the client through a well defined interface; if it
 just happens to have the same name as the property itself, its still the
 same concept.  you have the 'work' in the magic methods (at a minimum the
 initial part), instead of the getters and setters you would build yourself.
 and personally, i think it much cleaner to have separate methods for each of
 the properties rather than one big function which has to internally route
 control via some sort of logic, be it conditional, variable functions or
 w/e.
 besides which, for the magic methods to work, the variables have to be
 'inaccessible' according to the docs which means protected, private, or
 non-existent; and barring the case of non-existent we are right back in the
 realm of encapsulation.
 unless you meant something different by 'trapping the property accessor';
 which you usually do pull some unexpected stuff so im waiting for your next
 clever example to prove me wrong :D

Nope, the point is moot. If I've made my properties publicly accessible,
now, due to the ability to trap via __get() or __set(), I can remove
them and handle them. Thus, I can retrospectively change the semantics
without care for having exposed the properties themselves. The point is
moot here because the option now exists to enhance properties at a later
date without the need to drive the enhancements through a method the
user must call (the details of __get() and __set() are hidden from the
user of the properties ;) 

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Fri, Apr 18, 2008 at 1:42 PM, Robert Cummings [EMAIL PROTECTED]
wrote:

 Nope, the point is moot. If I've made my properties publicly accessible,
 now, due to the ability to trap via __get() or __set(), I can remove
 them and handle them. Thus, I can retrospectively change the semantics
 without care for having exposed the properties themselves. The point is
 moot here because the option now exists to enhance properties at a later
 date without the need to drive the enhancements through a method the
 user must call (the details of __get() and __set() are hidden from the
 user of the properties ;)


i see your rationale now, and yes i agree, using the magic methods does
afford the ability to make transparent changes and thats great.  however,
what im saying is thats still encapsulation, just a different way of
attaining it.  and the other negative of that approach is having to bulk up
the logic in the magic methods.  i tend to use them to handle attempts to
access non-existent params.
actually, tho drifting a bit; i think the __call() magic method is great
because it allows handling of what would otherwise be a fatal error when
trying to invoke a non-existent class method.

-nathan


Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Robert Cummings

On Fri, 2008-04-18 at 13:54 -0600, Nathan Nobbe wrote:
 On Fri, Apr 18, 2008 at 1:42 PM, Robert Cummings [EMAIL PROTECTED]
 wrote:
 
  Nope, the point is moot. If I've made my properties publicly accessible,
  now, due to the ability to trap via __get() or __set(), I can remove
  them and handle them. Thus, I can retrospectively change the semantics
  without care for having exposed the properties themselves. The point is
  moot here because the option now exists to enhance properties at a later
  date without the need to drive the enhancements through a method the
  user must call (the details of __get() and __set() are hidden from the
  user of the properties ;)
 
 
 i see your rationale now, and yes i agree, using the magic methods does
 afford the ability to make transparent changes and thats great.  however,
 what im saying is thats still encapsulation, just a different way of
 attaining it.

I'm not arguing against encapsulation, only indicating that there's no
longer a point to differentiating between method wrapping and property
access in PHP (although maybe there's some fringe differences-- I
haven't played with it much at this time).

   and the other negative of that approach is having to bulk up
 the logic in the magic methods.  i tend to use them to handle attempts to
 access non-existent params.

Why bulk up your magic methods? Keep them slim...

?php

class Foo
{
function __get( $name )
{
if( method_exists( $this, 'get'.ucFirst( $name ) ) )
{
return $this-{'get'.ucFirst( $name )}();
}
 
return null;
}
 
function getName()
{
return 'Namicus Orealeeyus';
}
}
 
$foo = new Foo();
echo $foo-name.\n;

?

Or if you want to pick and choose...

?php

class Foo
{
function __get( $name )
{
static $map = array
(
'name' = 'getName',
);

if( isset( $map[$name] ) )
{
return $this-{$map[$name]}();
}
 
return null;
}
 
function getName()
{
return 'Namicus Orealeeyus';
}
}

?

 actually, tho drifting a bit; i think the __call() magic method is great
 because it allows handling of what would otherwise be a fatal error when
 trying to invoke a non-existent class method.

Very useful for things like SOAP.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PHP5 and the DOM model

2008-04-18 Thread Nathan Nobbe
On Fri, Apr 18, 2008 at 2:28 PM, Robert Cummings [EMAIL PROTECTED]
wrote:


 On Fri, 2008-04-18 at 13:54 -0600, Nathan Nobbe wrote:
  On Fri, Apr 18, 2008 at 1:42 PM, Robert Cummings [EMAIL PROTECTED]
  wrote:
 
   Nope, the point is moot. If I've made my properties publicly
 accessible,
   now, due to the ability to trap via __get() or __set(), I can remove
   them and handle them. Thus, I can retrospectively change the semantics
   without care for having exposed the properties themselves. The point
 is
   moot here because the option now exists to enhance properties at a
 later
   date without the need to drive the enhancements through a method the
   user must call (the details of __get() and __set() are hidden from the
   user of the properties ;)
 
 
  i see your rationale now, and yes i agree, using the magic methods does
  afford the ability to make transparent changes and thats great.
  however,
  what im saying is thats still encapsulation, just a different way of
  attaining it.

 I'm not arguing against encapsulation, only indicating that there's no
 longer a point to differentiating between method wrapping and property
 access in PHP (although maybe there's some fringe differences-- I
 haven't played with it much at this time).

and the other negative of that approach is having to bulk up
  the logic in the magic methods.  i tend to use them to handle attempts
 to
  access non-existent params.

 Why bulk up your magic methods? Keep them slim...

 ?php

 class Foo
 {
function __get( $name )
{
if( method_exists( $this, 'get'.ucFirst( $name ) ) )
{
return $this-{'get'.ucFirst( $name )}();
}

return null;
}

function getName()
{
return 'Namicus Orealeeyus';
}
 }

 $foo = new Foo();
 echo $foo-name.\n;

 ?

 Or if you want to pick and choose...

 ?php

 class Foo
 {
function __get( $name )
{
static $map = array
(
'name' = 'getName',
);

if( isset( $map[$name] ) )
{
return $this-{$map[$name]}();
}

return null;
}

function getName()
{
return 'Namicus Orealeeyus';
}
 }

 ?


i know; variable functions are cool, but still, i guess it comes down to a
matter of prefernce

class Foo
{
   function __get( $name )
   {
   if( !is_set( $this-$name) )
   {
   // some logic for handling non-existent getters
   }

   return null;
   }

  /// only getters i care about
  function getStuff() {}
 /// etc ..
}
?

-nathan


Re: [PHP] PHP5 strtotime

2008-03-10 Thread Larry Garfield
On Monday 10 March 2008, Samuel Marshall wrote:
 I use PayPal as my ecommerce solution and I have a PHP script that captures
 variables posted from PayPal to populate my database. The time variable
 string is sent in the following format: HH:MM:SS DD Mmm YY,  PST. The
 script worked fine but since I upgraded to PHP5 the dates inputted into my
 database (MySQL) are showing some date in 1969. Can anyone say what is
 causing this or how to correct it? Thanks.

 Samuel Marshall

PHP's error value for dates translates to 6 PM 31 December 1969 when 
formatted, that is, right before the Epoc.  That happens when you feed 
strtotime a string it can't parse, for instance.  Looking at the string you 
list, the year is listed twice.  I very much doubt strtotime can grok that.  
You'll need to do at least some manual parsing of the date string.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP5 Speed Issues

2008-01-01 Thread Arvids Godjuks
Hi everyone!

Generaly author of the first e-mail is right. Ofcource, crawling over the
code and getting out of it a few milliseconds off doesn't make it worth, but
you can learn what is good and what is bad and write your code correctly
from the start.
Why not to use
foreach ($data as $value)
if it's better - faster and takes less memory. That's just a habbit on code
style.
I can bet, that nobody knows or remembers that echo has alternative syntax,
with works faster and is easier to write if you cave to echo a complex
string with many variables and static text, for example

The ordinary:
echo 'Hi! My name is '.$_GET['name'].'. I'm '.$_GET['age'].' and I live in
'.$_GET['country'].'.';

The alternative:
 echo 'Hi! My name is', $_GET['name'], '. I'm ', $_GET['age'], ' and I live
in ', $_GET['country'], '.';

I have an aplication with doesn't eat all CPU, just about 50-60%, but it
eats all 3GB of ram. And not because it is poorly written. It serves ~160
000 - 170 000 requests/hour, that's ~3 960 000 hits a day + another 600 000
hits to the application's WEB part. Just one server could handle, but it
can't because of WEB server's FastCGI implementation (they have a patch for
that soon released).
Just ONE Intel E6600 server with Lighttpd and PHP can handle such load if
the code is optimised and written correctly.


Re: [PHP] PHP5 Speed Issues

2007-12-31 Thread Richard Lynch
On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote:
 Hi Fellows,

 I figured out, that PHP5 runs faster when I am not inherit classes,
 I hope I use the right word.

 I mean the class sub_class extends main_class notation.

 As well I figured out, that I in most cases should references in
 foreach loops. like

 foreach($array as $key = $value) {

 }

 Lots of memory is saved by that.

 Now I would like to know, what other speed improvements might be
 possible. What about autoload of classes, will it improve speed
 when I throw the code out?

 Are there other things I should take care of.

 I would like to know as much as possible. Please go deep into your-
 self and tell me every little thing on how you improved your applica-
 tions for speed and memory optimisation, to make this thread the best
 compendium on performance and memory optimisation.

 Thank you very much, fellows and a merry merry christmas!

I never optimize code unless there's a problem with its performance...

Why one would tweak code endlessly to maximize performance when that's
not needed is beyond me...

But maybe I'm just a Luddite.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] PHP5 Speed Issues

2007-12-31 Thread Michael McGlothlin

Richard Lynch wrote:

On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote:
  

Hi Fellows,

I figured out, that PHP5 runs faster when I am not inherit classes,
I hope I use the right word.

I mean the class sub_class extends main_class notation.

As well I figured out, that I in most cases should references in
foreach loops. like

foreach($array as $key = $value) {

}

Lots of memory is saved by that.

Now I would like to know, what other speed improvements might be
possible. What about autoload of classes, will it improve speed
when I throw the code out?

Are there other things I should take care of.

I would like to know as much as possible. Please go deep into your-
self and tell me every little thing on how you improved your applica-
tions for speed and memory optimisation, to make this thread the best
compendium on performance and memory optimisation.

Thank you very much, fellows and a merry merry christmas!



I never optimize code unless there's a problem with its performance...

Why one would tweak code endlessly to maximize performance when that's
not needed is beyond me...

But maybe I'm just a Luddite.

  
Hardware is cheaper than man hours. Just throw more CPU power at the 
problem.


--
Michael McGlothlin
Southwest Plumbing Supply

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



Re: [PHP] PHP5 Speed Issues

2007-12-31 Thread Nathan Nobbe
On Dec 31, 2007 3:37 PM, Michael McGlothlin [EMAIL PROTECTED] wrote:

 Richard Lynch wrote:
  On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote:
 
  Hi Fellows,
 
  I figured out, that PHP5 runs faster when I am not inherit classes,
  I hope I use the right word.
 
  I mean the class sub_class extends main_class notation.
 
  As well I figured out, that I in most cases should references in
  foreach loops. like
 
  foreach($array as $key = $value) {
 
  }
 
  Lots of memory is saved by that.
 
  Now I would like to know, what other speed improvements might be
  possible. What about autoload of classes, will it improve speed
  when I throw the code out?
 
  Are there other things I should take care of.
 
  I would like to know as much as possible. Please go deep into your-
  self and tell me every little thing on how you improved your applica-
  tions for speed and memory optimisation, to make this thread the best
  compendium on performance and memory optimisation.
 
  Thank you very much, fellows and a merry merry christmas!
 
 
  I never optimize code unless there's a problem with its performance...
 
  Why one would tweak code endlessly to maximize performance when that's
  not needed is beyond me...
 
  But maybe I'm just a Luddite.
 
 
 Hardware is cheaper than man hours. Just throw more CPU power at the
 problem.


thats only true until poorly designed software cant be spread across
machines
due to a monolithic nature.
get an opcode cache and index the database; that will probly absolve any
noticeable
speed problems.

-nathan


Re: [PHP] PHP5 Speed Issues

2007-12-31 Thread Michael McGlothlin

Nathan Nobbe wrote:
On Dec 31, 2007 3:37 PM, Michael McGlothlin [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Richard Lynch wrote:
 On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote:

 Hi Fellows,

 I figured out, that PHP5 runs faster when I am not inherit
classes,
 I hope I use the right word.

 I mean the class sub_class extends main_class notation.

 As well I figured out, that I in most cases should references in
 foreach loops. like

 foreach($array as $key = $value) {

 }

 Lots of memory is saved by that.

 Now I would like to know, what other speed improvements might be
 possible. What about autoload of classes, will it improve speed
 when I throw the code out?

 Are there other things I should take care of.

 I would like to know as much as possible. Please go deep into
your-
 self and tell me every little thing on how you improved your
applica-
 tions for speed and memory optimisation, to make this thread
the best
 compendium on performance and memory optimisation.

 Thank you very much, fellows and a merry merry christmas!


 I never optimize code unless there's a problem with its
performance...

 Why one would tweak code endlessly to maximize performance when
that's
 not needed is beyond me...

 But maybe I'm just a Luddite.


Hardware is cheaper than man hours. Just throw more CPU power at the
problem.


thats only true until poorly designed software cant be spread across 
machines

due to a monolithic nature.
get an opcode cache and index the database; that will probly absolve 
any noticeable

speed problems.

-nathan
Well obviously you can always write horrible code but if you write code 
that is easy to maintain it's usually not that kind of code.


--
Michael McGlothlin
Southwest Plumbing Supply

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



Re: [PHP] PHP5 Speed Issues

2007-12-31 Thread Nathan Nobbe
On Dec 31, 2007 3:47 PM, Michael McGlothlin [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
  On Dec 31, 2007 3:37 PM, Michael McGlothlin [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED] wrote:
 
  Richard Lynch wrote:
   On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote:
  
   Hi Fellows,
  
   I figured out, that PHP5 runs faster when I am not inherit
  classes,
   I hope I use the right word.
  
   I mean the class sub_class extends main_class notation.
  
   As well I figured out, that I in most cases should references in
   foreach loops. like
  
   foreach($array as $key = $value) {
  
   }
  
   Lots of memory is saved by that.
  
   Now I would like to know, what other speed improvements might be
   possible. What about autoload of classes, will it improve speed
   when I throw the code out?
  
   Are there other things I should take care of.
  
   I would like to know as much as possible. Please go deep into
  your-
   self and tell me every little thing on how you improved your
  applica-
   tions for speed and memory optimisation, to make this thread
  the best
   compendium on performance and memory optimisation.
  
   Thank you very much, fellows and a merry merry christmas!
  
  
   I never optimize code unless there's a problem with its
  performance...
  
   Why one would tweak code endlessly to maximize performance when
  that's
   not needed is beyond me...
  
   But maybe I'm just a Luddite.
  
  
  Hardware is cheaper than man hours. Just throw more CPU power at the
  problem.
 
 
  thats only true until poorly designed software cant be spread across
  machines
  due to a monolithic nature.
  get an opcode cache and index the database; that will probly absolve
  any noticeable
  speed problems.
 
  -nathan
 Well obviously you can always write horrible code but if you write code
 that is easy to maintain it's usually not that kind of code.


thats pretty subjective;  ive worked w/ plenty of 'easy to maintain' code
that could
only have hardware thrown at it by a load balancer.  which i consider a real
mess.
even then the design of the load balancer will have to maintain request
forwarding
to particular hosts unless the code already supports or is given support for
session
storage in a common location all the webservers can address.
i personally am not a fan of the 'just throw hardware at it' adage, if it
can be called that.
i was recently at the d.c. php conference and heard a talk from a gentleman
on behalf
of yahoo.  he says they are *very* picky about getting new hardware; yahoo
wants clear
rationale for the addition of any new hardware into the system.  in short;
they advocate
writing solid code because it saves them money in the long run.
what i see happening when people throw hardware at their problem is that in
early stages
it works great.  then further down the road the software is unable to be
easily spread to
multiple systems and then guess what; you end up spending man hours to do
something that
could have been done in the first place.  another issue is randomly added
machines can be
hard to maintain because their roles are not clearly defined.
what im saying is adding hardware to a system is natural and relevant, but
ensure it is a
good decision by evaluating alternatives before arbitrarily 'throwing
hardware at the problem'.

-nathan


Re: [PHP] php5 - possible bug discovered

2007-10-09 Thread David Restall - System Administrator
Hi Robert, Stut  List

Thanks for your replies which arrived after I had gone to bed |-Z

Robert :-

 In PHP5 objects are no longer copied when assigned. Instead the object's
 handle is assigned (similar to a reference but not quite). So the
 behaviour is as expected.

Stut :-

  I think I have discovered a bug in php5.  If I haven't, I've discovered
  a bug in the documentation or a bug in my brain.
 
 Start here: http://php.net/language.oop5.cloning

It's amazing what a good night's sleep will do :-)

I could not find that page last night even though I was sure it must
have existed and I can see that it is a well documented and encountered
problem.

My main obesrvation is that I'm glad that I decided to revisit all my
old PHP4 stuff and rewrite or clean it up.  I have hundreds of

$Working_Class = $Under_Class;

lines in my code as well as

$Upper_Class =  $Aristocracy;

lines too.  I think the documentation on references needs updating to
reflect PHP 5's behaviour a little more accurately because I can see
this causing serious problems to somebody just copying their code blindly.

I have just built a client a development server using php5 instead of
php4 and turned zend.ze1_compatibility_mode on so that their old CMS would
work - I just hadn't realised that the cloning problem was solved by this.

Oh well, now I'm fresh I can crack on :-)

TTFN


D
php/general-2007-10-09.tx  [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   php-general
++
| Dave Restall, Computer Nerd, Cyclist, Radio Amateur G4FCU, Bodger  |
| Mob +44 (0) 7973 831245  Skype: dave.restall Radio: G4FCU  |
| email : [EMAIL PROTECTED] Web : Not Ready Yet :-(   |
++
| birth, n:  |
| The first and direst of all disasters. |
| -- Ambrose Bierce, The Devil's Dictionary|
++

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



Re: [PHP] php5 - possible bug discovered

2007-10-09 Thread Stut

David Restall - System Administrator wrote:

My main obesrvation is that I'm glad that I decided to revisit all my
old PHP4 stuff and rewrite or clean it up.  I have hundreds of

$Working_Class = $Under_Class;

lines in my code as well as

$Upper_Class =  $Aristocracy;

lines too.  I think the documentation on references needs updating to
reflect PHP 5's behaviour a little more accurately because I can see
this causing serious problems to somebody just copying their code blindly.


This change was made very clear in the changelog for PHP5. Whenever you 
change to a different PHP version the changelog should be the first 
thing you read. If you try to read the documentation to pick out the 
changes you'll miss something.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP5 under IIS6

2007-10-08 Thread Carlton Whitehead
Hi Alberto,

Try using the php5isapi.dll instead of CGI.  Make sure you have an entry for 
PHP5 in your Web Service Extensions list, and that it is marked as Allowed.  
Also, open the properties of your Web Sites folder in IIS Manager, go to the 
Home Directory Tab, click Configuration, and make sure the php5isapi.dll is 
mapped to the .php extension.

Regards,
Carlton Whitehead

- Original Message -
From: Alberto García Gómez [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Monday, October 8, 2007 9:57:42 AM (GMT-0500) America/New_York
Subject: [PHP] PHP5 under IIS6

Hi fellows:

I'm trying to mount PHP5 ( the last stable version from php.net) under a 
IIS6 (win2k3 SP2), and when I run the .msi and it finish it said that is not 
possible the configure httpd.conf, which is a very big mistake 'cause I'm 
specify that I use IIS6.

After that I try making a manual configuration and I recive a CGI error.

I need help ASAP. 


Este correo ha sido enviado desde el Politécnico de Informática Carlos Marx 
de Matanzas.
La gran batalla se librará en el campo de las ideas

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

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



Re: [PHP] php5 - possible bug discovered

2007-10-08 Thread Robert Cummings
In PHP5 objects are no longer copied when assigned. Instead the object's
handle is assigned (similar to a reference but not quite). So the
behaviour is as expected.

Cheers,
Rob.


On Mon, 2007-10-08 at 21:42 +0100, David Restall - System Administrator
wrote:
 Hi,
 
 I think I have discovered a bug in php5.  If I haven't, I've discovered
 a bug in the documentation or a bug in my brain.
 
 php -v :-
 
 PHP 5.2.3 (cli) (built: Jun 26 2007 15:38:48) 
 Copyright (c) 1997-2007 The PHP Group
 Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
 
 I've attached a code snippet for those that want to save it and try
 running it and it's also pasted here :-
 
 
 ?php
 
 class Class_1
 {
 private $Text;
 
 function __construct($Text)
   {
   $this-Text = $Text;
   }
 
 function Set($Text)
   {
   $this-Text = $Text;
   }
 
 function Display()
   {
   print $this-Text . \n;
   }
 } // End Class_1
 
 class Class_2
 {
 private $Text;
 private $C1;
 
 function __construct($Text)
   {
   $this-Text = $Text;
 
   $this-C1 = new Class_1('From David');
   }
 
 function Set_C1($Text)
   {
   $this-C1-Set($Text);
   }
 
 function Display()
   {
   print $this-Text . \n;
   $this-C1-Display();
   }
 } // End Class_2
 
 print Below is T1\n;
 
 $T1 = new Class_1('Hello');
 $T1-Display();
 
 print Below is T2\n;
 $T2 = new Class_2('World');
 $T2-Display();
 
 print Copying T2\n;
 
 $T3 = $T2;
 
 print T2 Copied, original value is :-\n;
 
 $T2-Display();
 
 print Copy of T2 (T3) value is :- \n;
 
 $T3-Display();
 
 print Changing T3\n;
 
 $T3-Set_C1(This clears Dave);
 
 print T3 Change complete, new value is :-\n;
 
 $T3-Display();
 
 print Below is T2 which shouldn't have changed !!! \n;
 
 $T2-Display();
 
 // var_dump($T1);
 
 ?
 
 
 
 The output it produces is :-
 
 % php -e bug.php
 Below is T1
 Hello
 Below is T2
 World
 From David
 Copying T2
 T2 Copied, original value is :-
 World
 From David
 Copy of T2 (T3) value is :- 
 World
 From David
 Changing T3
 T3 Change complete, new value is :-
 World
 This clears Dave
 Below is T2 which shouldn't have changed !!! 
 World
 This clears Dave
 %
 
 Now I would expect that $T2 would not change when I changed $T3.
 Reading the documentation :-
 
 http://www.php.net/manual/en/language.references.whatdo.php
 
 ... Note:  Not using the  operator causes a copy of the object to be
 made. If you use $this in the class it will operate on the current
 instance of the class. The assignment without  will copy the instance
 (i.e. the object) and $this will operate on the copy, which is not
 always what is desired. Usually you want to have a single instance to
 work with, due to performance and memory consumption issues.
 
 This effectively states that $T3 is a 'COPY' of $T2 and $T3 works on the
 copy, not the master yet in the above snippet, the copy and the master
 have both been changed.  Further documentation mentions that the copy
 starts off as a reference and only becomes a copy when it is changed.
 This doesn't seem to be happening.
 
 I found this because in my actual application I was using :-
 Master.class
 ...
 $Clone = $this;
 
 $Clone-Do_Something;
 
 
 and later in master.class I did :-
 
 $this-Do_Something_Else
 
 and php barfed with :-
 
 PHP Fatal error:  Call to a member function Function_Name() on a non-object 
 
 I had deleted the missing object in $Clone but not in the master (this
 was the whole idea of working on $Clone - I didn't want to delete the
 object in the master !!).
 
 I can't find anything similar in the bug database on php.net (but I may
 be looking in the wrong place) and I can't believe that I'm the first
 person to encounter this.
 
 Can anybody explain if this is a bug or if I have misunderstood the
 documentation ?
 
 TTFN
 
 
 
 D
 php/general-2007-10-08.tx  php-general
 ++
 | Dave Restall, Computer Nerd, Cyclist, Radio Amateur G4FCU, Bodger  |
 | Mob +44 (0) 7973 831245  Skype: dave.restall Radio: G4FCU  |
 | email : [EMAIL PROTECTED] Web : Not Ready Yet :-(   
 |
 ++
 | Good salesmen and good repairmen will never go hungry. |
 | -- R. E. Schenk|
 ++
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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

Re: [PHP] php5 - possible bug discovered

2007-10-08 Thread Stut

David Restall - System Administrator wrote:

I think I have discovered a bug in php5.  If I haven't, I've discovered
a bug in the documentation or a bug in my brain.


Start here: http://php.net/language.oop5.cloning

-Stut

--
http://stut.net/

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



Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5

2007-09-07 Thread Roman

On Thu, 06 Sep 2007 15:57:57 +0300, Tijnema [EMAIL PROTECTED] wrote:


On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote:

I'm a german web-designer living in Turkey.
Sometimes I use opensource software like gallery2 or WP to have  
customers

have some
nice web albums or blog. The turkish translation files of such  
opensource

software
usually use gettext and .po files for i18n and are always a bit behind  
the

translation
status of other european languages.

I decided to work a bit on some of those tr.po files on my local linux  
box

(opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I
started the
test phase in turkish I couldn't test because of strange errors.
I contacted the forum of gallery2 and after investigating the problem I
stumbled over an answer of bug #35050 at bugs.php.net:

  http://bugs.php.net/bug.php?id=35050

and its status: WONT FIX

Now that's really great. It means that turkish hosting providers cannot
use php5 at all!
And as of the news on php.net php4 will not be supported or developed  
any

further
after the end of 2007! Will Turks really have now to wait for a php6?
When will that come out?
That's seems to me to be a sort of discrimination of turkish language in
php5.
Is it technical so difficult to develop a patch for this bug?

Sincerely



Well, only 1 hour later than your email, there has been posted a patch
on the bug page that fixes it.

Tijnema




I had a look at the patch under http://www.topolis.lt/php/#35050 and saw it
did not work for my system (php5.2.0) I wrote to the author of the patch  
and

got this answer:


Patch is written for PHP 5.2.5-dev. It should work in 6.0-dev and PHP
5.2.1 or later version. Any version later than 2006-12-05.


But he also said:


If you need workaround, just set LC_CTYPE locale to C. It also deals with
programming mistakes in PHP scripts.setlocale(LC_ALL,'tr_TR.UTF-8');
setlocale(LC_CTYPE, 'C');


and that seems to work - at least in case of my gallery2 under php5.2.0.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5

2007-09-06 Thread Tijnema
On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote:
 I'm a german web-designer living in Turkey.
 Sometimes I use opensource software like gallery2 or WP to have customers
 have some
 nice web albums or blog. The turkish translation files of such opensource
 software
 usually use gettext and .po files for i18n and are always a bit behind the
 translation
 status of other european languages.

 I decided to work a bit on some of those tr.po files on my local linux box
 (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I
 started the
 test phase in turkish I couldn't test because of strange errors.
 I contacted the forum of gallery2 and after investigating the problem I
 stumbled over an answer of bug #35050 at bugs.php.net:

   http://bugs.php.net/bug.php?id=35050

 and its status: WONT FIX

 Now that's really great. It means that turkish hosting providers cannot
 use php5 at all!
 And as of the news on php.net php4 will not be supported or developed any
 further
 after the end of 2007! Will Turks really have now to wait for a php6?
 When will that come out?
 That's seems to me to be a sort of discrimination of turkish language in
 php5.
 Is it technical so difficult to develop a patch for this bug?

 Sincerely


Well, only 1 hour later than your email, there has been posted a patch
on the bug page that fixes it.

Tijnema


-- 
If this is a mailing list: DO NOT TOP POST! why?:
http://www.caliburn.nl/topposting.html

Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! -
http://gpcc.tijnema.info

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



Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5

2007-09-06 Thread Dan Shirah
Now that's service!

On 9/6/07, Tijnema [EMAIL PROTECTED] wrote:

 On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote:
  I'm a german web-designer living in Turkey.
  Sometimes I use opensource software like gallery2 or WP to have
 customers
  have some
  nice web albums or blog. The turkish translation files of such
 opensource
  software
  usually use gettext and .po files for i18n and are always a bit behind
 the
  translation
  status of other european languages.
 
  I decided to work a bit on some of those tr.po files on my local linux
 box
  (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I
  started the
  test phase in turkish I couldn't test because of strange errors.
  I contacted the forum of gallery2 and after investigating the problem I
  stumbled over an answer of bug #35050 at bugs.php.net:
 
http://bugs.php.net/bug.php?id=35050
 
  and its status: WONT FIX
 
  Now that's really great. It means that turkish hosting providers cannot
  use php5 at all!
  And as of the news on php.net php4 will not be supported or developed
 any
  further
  after the end of 2007! Will Turks really have now to wait for a php6?
  When will that come out?
  That's seems to me to be a sort of discrimination of turkish language in
  php5.
  Is it technical so difficult to develop a patch for this bug?
 
  Sincerely
 

 Well, only 1 hour later than your email, there has been posted a patch
 on the bug page that fixes it.

 Tijnema


 --
 If this is a mailing list: DO NOT TOP POST! why?:
 http://www.caliburn.nl/topposting.html

 Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! -
 http://gpcc.tijnema.info

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




Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5

2007-09-06 Thread Roman

On Thu, 06 Sep 2007 15:57:57 +0300, Tijnema [EMAIL PROTECTED] wrote:


On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote:

I'm a german web-designer living in Turkey.
Sometimes I use opensource software like gallery2 or WP to have  
customers

have some
nice web albums or blog. The turkish translation files of such  
opensource

software
usually use gettext and .po files for i18n and are always a bit behind  
the

translation
status of other european languages.

I decided to work a bit on some of those tr.po files on my local linux  
box

(opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I
started the
test phase in turkish I couldn't test because of strange errors.
I contacted the forum of gallery2 and after investigating the problem I
stumbled over an answer of bug #35050 at bugs.php.net:

  http://bugs.php.net/bug.php?id=35050

and its status: WONT FIX

Now that's really great. It means that turkish hosting providers cannot
use php5 at all!
And as of the news on php.net php4 will not be supported or developed  
any

further
after the end of 2007! Will Turks really have now to wait for a php6?
When will that come out?
That's seems to me to be a sort of discrimination of turkish language in
php5.
Is it technical so difficult to develop a patch for this bug?

Sincerely



Well, only 1 hour later than your email, there has been posted a patch
on the bug page that fixes it.

Tijnema


Now that's great!

But...
I had a view in my php5.2.0 source package in the Zend folder
(phpinfo says: Zend Engine v2.2.0) for the file to be patched
(zend_operators.c) and there is no such code in the file and no
#define zend_tolower(c)

What do I have to do now?

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



Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5

2007-09-06 Thread Eric Butera
On 9/6/07, Tijnema [EMAIL PROTECTED] wrote:
 On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote:
  I'm a german web-designer living in Turkey.
  Sometimes I use opensource software like gallery2 or WP to have customers
  have some
  nice web albums or blog. The turkish translation files of such opensource
  software
  usually use gettext and .po files for i18n and are always a bit behind the
  translation
  status of other european languages.
 
  I decided to work a bit on some of those tr.po files on my local linux box
  (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I
  started the
  test phase in turkish I couldn't test because of strange errors.
  I contacted the forum of gallery2 and after investigating the problem I
  stumbled over an answer of bug #35050 at bugs.php.net:
 
http://bugs.php.net/bug.php?id=35050
 
  and its status: WONT FIX
 
  Now that's really great. It means that turkish hosting providers cannot
  use php5 at all!
  And as of the news on php.net php4 will not be supported or developed any
  further
  after the end of 2007! Will Turks really have now to wait for a php6?
  When will that come out?
  That's seems to me to be a sort of discrimination of turkish language in
  php5.
  Is it technical so difficult to develop a patch for this bug?
 
  Sincerely
 

 Well, only 1 hour later than your email, there has been posted a patch
 on the bug page that fixes it.

 Tijnema


 --
 If this is a mailing list: DO NOT TOP POST! why?:
 http://www.caliburn.nl/topposting.html

 Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! -
 http://gpcc.tijnema.info

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



I wouldn't hold my breath on that.

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



Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 16:46 +0100, Steve Perkins wrote:

 I guess there are lots of workaround ways. I could write lots of
 middleman code in generic and use things like __set and __get etc but its
 lots of extra overhead. I also know I could use extends but that makes the
 code the wrong way around (MySQL_Driver would have to extend generic), hence
 the top-level application would have to include code to determine which
 driver to create rather than the db object determining its own connection
 driver to use. This is true also for just lumping everything in a single
 class per db type.

You want a factory class that creates an instance of the appropriate
driver object. The driver object SHOULD extend the generic class.
?php

class DbFactory
{
function __construct()
{
// :)
}

function getConnection( $type, $params )
{
if( $type == 'MySQL' )
{
return new DB_Driver_MySQL;
}
else
if( $type == 'ODBC' )
{
return new DB_Driver_ODBC;
}

return false;
}
}

class DB_Driver_Generic
{
public $var1;
public $var2;

function __construct()
{
}

function runQuery( $query )
{
}
}

class DB_Driver_MySQL extends DB_Driver_Generic
{
function __construct()
{
parent::__construct();
}
}

class DB_Driver_ODBC extends DB_Driver_Generic
{
function __construct()
{
parent::__construct();
}
}

?

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Nathan Nobbe

I also don't really get the idea of interface and abstract classes ? They
don't seem to be any practical use ? Maybe that's me ? Anyway, not really
relevant to this post ...


there is a lot of usefulness in these constructs; look into design patterns.
also, there are code libraries already written w/ the abstraction you are
trying to develop.
im not discouraging you from developing your own, but it may be helpful for
you to study some of the other code.
check out
http://pear.php.net/package/MDB2
http://ez.no/doc/components/view/2007.1/(file)/classtrees_Database.html
http://www.onphp.org/doxy/trunk/

-nathan
ps.

i believe interjinn provides a db layer as well :

On 7/11/07, Steve Perkins [EMAIL PROTECTED] wrote:


OK, so that came out fairly illegible. Try again:

Hi, new to PHP5 (and the forums evidently !) and I have a question about
the
object model.

I want to be able to create a class which is allows abstraction from
specifics. So for one example, imagine a generic database connection
wrapper
which can have multiple drivers depending on the database used. Some of
the
functionality is generic, some is database specific (mysql_ , odbc_). So:

Class MySQL_driver {
public prop1 ;
public connect() {
echo Foo;
}
public runquery() {
echo Foo;
}
...
}

Class ODBC_driver {
public prop1 ;
public connect() {
echo Foo;
}
public runquery() {
echo Foo;
}
...
}

Class generic {
public $driver = null ;
function __construct($connection_type) {
if $this-connection_type = MySQL {
$this-driver = new MySQL_Driver ;
} else {
$this-driver = new ODBC_Driver ;
}
}

// Using the non-generic connect() from the selected driver

function authenticate {
$this-driver-prop1 = fooey

// These references work fine from within
// the generic class

echo $this-driver-prop1 ;
echo $this-driver-function1 ;
}

// Report non-generic errors from the selected driver

function errors {
}
function debug {
}

...

}

$gen = new generic(MySQL) ;

// Instantiate the generic database object, which
// determines its own driver

$gen-driver-prop1 = fooey

// but they fail from here

echo $gen-driver-prop1 ;
echo $gen-driver-function1 ;

// this works ok though, so everything is created
// correctly

$gen-authenticate() ;


So I want to access generic functions as $generic-authenticate(), and
database specific functions $generic-driver-runquery. This allows the
top
level code to be able to be completely generic and not know anything about
the underlying database.

But I can't ! I can't find a way of accessing the encapsulated object
(driver) from the instantiator of generic. Is it possible ?

I guess there are lots of workaround ways. I could write lots of
middleman code in generic and use things like __set and __get etc but
its
lots of extra overhead. I also know I could use extends but that makes the
code the wrong way around (MySQL_Driver would have to extend generic),
hence
the top-level application would have to include code to determine which
driver to create rather than the db object determining its own connection
driver to use. This is true also for just lumping everything in a single
class per db type.

Surely it must be possible ? Or am I missing something ?

I also don't really get the idea of interface and abstract classes ? They
don't seem to be any practical use ? Maybe that's me ? Anyway, not really
relevant to this post ...

Please, please can someone help !!

Thanks

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

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




Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 12:07 -0400, Nathan Nobbe wrote:
  I also don't really get the idea of interface and abstract classes ? They
  don't seem to be any practical use ? Maybe that's me ? Anyway, not really
  relevant to this post ...
 
 there is a lot of usefulness in these constructs; look into design patterns.
 also, there are code libraries already written w/ the abstraction you are
 trying to develop.
 im not discouraging you from developing your own, but it may be helpful for
 you to study some of the other code.
 check out
 http://pear.php.net/package/MDB2
 http://ez.no/doc/components/view/2007.1/(file)/classtrees_Database.html
 http://www.onphp.org/doxy/trunk/
 
 -nathan
 ps.
 
 i believe interjinn provides a db layer as well :

It does :) It was especially important in PHP4 since there was no PDO as
there is now in PHP5. Not that I'm particularly familiar with PDO (maybe
it has deficiencies?).

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Jochem Maas
some ideas about class design:

1. properties should normally (read almost always) be private.
2. the apps interface to the DB [connection] is via the 'generic'
class, the app should have to know nothing about the drive object and
should have no direct access to it.
3. use an interface definition for your drivers (so they all share a
common set of method ... a common interface ;-))

this leaves you with the problem of wanting to write as little boilerplate
code for making the functionality each driver class implements available via
the 'generic' class.

I would suggest either a few simple functions like so:

class DB {
function query() {
$args = func_get_args();
return call_user_func_array(array($this-driver, __FUNCTION__), 
$args);
}
}

which you can simplify into something like:

class DB {
function __call($meth, $args) {
$func = array($this-driver, $meth)
if (!is_callable($func))
throw new Exception('undefined interface: 
'.__CLASS__.'::'$meth);

return call_user_func_array($func, $args);
}
}

just an idea :-) ... this seems to me to be something along the decorator 
pattern,
you could choose to do something along the lines of the factory pattern, where 
by
your factory returns a 'driver' object which your application uses (not caring 
what
class of driver it is) ... this would also require that your driver classes 
share a
common interface (actually using a interface definition to enforce it is a 
seperate issue).

an interface example:

interface DBDriver {
function query($sql, $args);
function commit($id);
function rollback($id);
}

class MySQL_DBDriver implements DBDriver {
function query($sql, $args) { return mysql_query($sql, $args); }
function commit($id);   { return true; }
function rollback($id); { return true; }
}


Steve Perkins wrote:

 
 // but they fail from here
 
 echo $gen-driver-prop1 ; 
 echo $gen-driver-function1 ;

what fails exactly? what is the error?

 
 // this works ok though, so everything is created
 // correctly
 
 $gen-authenticate() ; 
 

PS. I would hazard a guess and say the generic class is not very generic -
it's quite specifically a 'database' class, it is an 'abstract' class (not in 
the
php syntax sense) in that the DBMS specifics are hidden away in helper/plugin 
classes.

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



Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Nathan Nobbe

Robert,

I looked at your code in InterJinn a couple of times; i havent gone over all
of it mind you but it looks pretty sweet.
have you had a look at any of the other frameworks i mentioned earlier in
this thread?
ez components, onPHP, and now there is a new one ive found (in recent
thread) Radicore.  i really like the xsl approach
for templates.

All,
also, more on topic; there are many different ways to use interfaces and
abstract classes in many different design patterns.
they all have purpose, pros and cons.  take for instance factory method and
abstract factory; where the former uses inheritance
the later uses composition.  the former can produce only a single class of
products, but the abstract base class rarely needs revision;
whereas the later can produce sets of related product classes; yet every
time a new product class is needed or deprecated the
abstract factory [interface] needs revision.

Steve,
you might also check out
http://www.phppatterns.com/docs/start
i dont think its been maintained in a while, but its a great place to start.

also, i think PDO is pretty sweet, but really its only the base of a strong
db abstraction layer, such as what youll find in ez components.

-nathan
ps.
i cant decide if i should build my own db layer around pdo or go for a
pre-built one from an aforementioned framework; only time will tell :

On 7/11/07, Jochem Maas [EMAIL PROTECTED] wrote:


some ideas about class design:

1. properties should normally (read almost always) be private.
2. the apps interface to the DB [connection] is via the 'generic'
class, the app should have to know nothing about the drive object and
should have no direct access to it.
3. use an interface definition for your drivers (so they all share a
common set of method ... a common interface ;-))

this leaves you with the problem of wanting to write as little boilerplate
code for making the functionality each driver class implements available
via
the 'generic' class.

I would suggest either a few simple functions like so:

class DB {
function query() {
$args = func_get_args();
return call_user_func_array(array($this-driver,
__FUNCTION__), $args);
}
}

which you can simplify into something like:

class DB {
function __call($meth, $args) {
$func = array($this-driver, $meth)
if (!is_callable($func))
throw new Exception('undefined interface:
'.__CLASS__.'::'$meth);

return call_user_func_array($func, $args);
}
}

just an idea :-) ... this seems to me to be something along the decorator
pattern,
you could choose to do something along the lines of the factory pattern,
where by
your factory returns a 'driver' object which your application uses (not
caring what
class of driver it is) ... this would also require that your driver
classes share a
common interface (actually using a interface definition to enforce it is a
seperate issue).

an interface example:

interface DBDriver {
function query($sql, $args);
function commit($id);
function rollback($id);
}

class MySQL_DBDriver implements DBDriver {
function query($sql, $args) { return mysql_query($sql, $args);
}
function commit($id);   { return true; }
function rollback($id); { return true; }
}


Steve Perkins wrote:


 // but they fail from here

 echo $gen-driver-prop1 ;
 echo $gen-driver-function1 ;

what fails exactly? what is the error?


 // this works ok though, so everything is created
 // correctly

 $gen-authenticate() ;


PS. I would hazard a guess and say the generic class is not very generic -
it's quite specifically a 'database' class, it is an 'abstract' class (not
in the
php syntax sense) in that the DBMS specifics are hidden away in
helper/plugin classes.

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




Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 12:50 -0400, Nathan Nobbe wrote:
 Robert,
 
 I looked at your code in InterJinn a couple of times; i havent gone over all
 of it mind you but it looks pretty sweet.

It's very different in many respects from other styles of coding. It's
an MVC approach for the most part but the way libraries are accessed is
different than what I've seen elsewhere. In general class names are only
used in two places... when extending a class, and in the registration of
a class to a service. Instead classes are registered as
services/libraries and instances are retrieved by a general factory
mechanism that returns the instance based on the service/library name.
In this way almost all aspects of the framework can be overloaded, even
if they are core features, without ever touching the core code itself or
ever having to change class references within your code since you can
just register a different class for the service and all existing uses of
that service will now use the newly registered version. This was very
useful even before PHP5 got autoload (and even still IMHO) because the
loader would load the class's code on an as requested basis.

 have you had a look at any of the other frameworks i mentioned earlier in
 this thread?
 ez components

I work with a version of ez components on almost a daily basis
(pre-existing CMS that a client had set up) ... it makes me scream
because their template engine is godawful because it uses a block
approach that requires changing the PHP code if you move blocks out of
registered nestings. It's absolutely horrible. The code for the classes
is generally disgusting also, but that's just my opinion. Fortunately, I
was allowed to hook in InterJinn as needed and so new stuff uses the ez
components framework bu generally punts the work to InterJinn modules /
services / and templates. We've found run time speed to be much greater
for those modules and the maintainability of the content is much, much,
easier.

 , onPHP, and now there is a new one ive found (in recent
 thread) Radicore.  i really like the xsl approach
 for templates.

XSL is nice, but it's complex for the average Joe content developer.
When I created InterJinn I wanted something with similar capabilities
but without the restriction of well-formed-ness for the HTML content in
general (so that existing content could still be adapted with minimal
disruption - my new site is XHTML strict). So I created custom tags that
can wrap well-formed or not-so-well formed content and process as
necessary. Generally speaking though the template engine isn't in any
way limited to just custom tags, it can include anything since it's
pluggable and extendable. Also, unlike most other template engines,
TemplateJinn compiles to the actual PHP code the web server loads, so
there's no run-time hit, and in fact, there can be a run time bonus on
some aspects. For instance headers, footers, etc, etc can be punted to
separate templates but at compile time they are brought together to
create the final page. That's not to say TemplateJinn can't be used at
run-time, it can be, and it is in the case of the ez components hooking
since ezcomponents uses a front end loader.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Richard Lynch
You probably ought to have:

class mysql_driver extends generic_driver {
}

Seems like that would be the most reasonable OOP model, imho.



That said, I suspect that if you do something like:

$driver = $this-driver;

You then may be able to access the driver-specific data using
$driver-propl; etc.

On Wed, July 11, 2007 10:46 am, Steve Perkins wrote:
 OK, so that came out fairly illegible. Try again:

 Hi, new to PHP5 (and the forums evidently !) and I have a question
 about the
 object model.

 I want to be able to create a class which is allows abstraction from
 specifics. So for one example, imagine a generic database connection
 wrapper
 which can have multiple drivers depending on the database used. Some
 of the
 functionality is generic, some is database specific (mysql_ , odbc_).
 So:

 Class MySQL_driver {
 public prop1 ;
 public connect() {
 echo Foo;
 }
 public runquery() {
 echo Foo;
 }
 ...
 }

 Class ODBC_driver {
 public prop1 ;
 public connect() {
 echo Foo;
 }
 public runquery() {
 echo Foo;
 }
 ...
 }

 Class generic {
 public $driver = null ;
 function __construct($connection_type) {
 if $this-connection_type = MySQL {
 $this-driver = new MySQL_Driver ;
 } else {
 $this-driver = new ODBC_Driver ;
 }
 }

   // Using the non-generic connect() from the selected driver

 function authenticate {
 $this-driver-prop1 = fooey

 // These references work fine from within
 // the generic class

 echo $this-driver-prop1 ;
 echo $this-driver-function1 ;
 }

   // Report non-generic errors from the selected driver

 function errors {
 }
 function debug {
 }

 ...

 }

 $gen = new generic(MySQL) ;

 // Instantiate the generic database object, which
 // determines its own driver

 $gen-driver-prop1 = fooey

 // but they fail from here

 echo $gen-driver-prop1 ;
 echo $gen-driver-function1 ;

 // this works ok though, so everything is created
 // correctly

 $gen-authenticate() ;


 So I want to access generic functions as $generic-authenticate(), and
 database specific functions $generic-driver-runquery. This allows
 the top
 level code to be able to be completely generic and not know anything
 about
 the underlying database.

 But I can't ! I can't find a way of accessing the encapsulated object
 (driver) from the instantiator of generic. Is it possible ?

 I guess there are lots of workaround ways. I could write lots of
 middleman code in generic and use things like __set and __get etc
 but its
 lots of extra overhead. I also know I could use extends but that makes
 the
 code the wrong way around (MySQL_Driver would have to extend generic),
 hence
 the top-level application would have to include code to determine
 which
 driver to create rather than the db object determining its own
 connection
 driver to use. This is true also for just lumping everything in a
 single
 class per db type.

 Surely it must be possible ? Or am I missing something ?

 I also don't really get the idea of interface and abstract classes ?
 They
 don't seem to be any practical use ? Maybe that's me ? Anyway, not
 really
 relevant to this post ...

 Please, please can someone help !!

 Thanks

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

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] PHP5 objects access/instantiation model (correction)

2007-07-11 Thread Steve Perkins
Yeah. I've been working on re-writing it using bits from everyone !! It's a
good learning process to find out how PHP handles OOP. I thoroughly
recommend it, it's the only way to learn. Some things just can't be learnt
from the manual!

Cheers All.

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: 11 July 2007 21:29
To: Steve Perkins
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP5 objects access/instantiation model (correction)

You probably ought to have:

class mysql_driver extends generic_driver { }

Seems like that would be the most reasonable OOP model, imho.



That said, I suspect that if you do something like:

$driver = $this-driver;

You then may be able to access the driver-specific data using
$driver-propl; etc.

On Wed, July 11, 2007 10:46 am, Steve Perkins wrote:
 OK, so that came out fairly illegible. Try again:

 Hi, new to PHP5 (and the forums evidently !) and I have a question 
 about the object model.

 I want to be able to create a class which is allows abstraction from 
 specifics. So for one example, imagine a generic database connection 
 wrapper which can have multiple drivers depending on the database 
 used. Some of the functionality is generic, some is database specific 
 (mysql_ , odbc_).
 So:

 Class MySQL_driver {
 public prop1 ;
 public connect() {
 echo Foo;
 }
 public runquery() {
 echo Foo;
 }
 ...
 }

 Class ODBC_driver {
 public prop1 ;
 public connect() {
 echo Foo;
 }
 public runquery() {
 echo Foo;
 }
 ...
 }

 Class generic {
 public $driver = null ;
 function __construct($connection_type) {
 if $this-connection_type = MySQL {
 $this-driver = new MySQL_Driver ;
 } else {
 $this-driver = new ODBC_Driver ;
 }
 }

   // Using the non-generic connect() from the selected driver

 function authenticate {
 $this-driver-prop1 = fooey

 // These references work fine from within
 // the generic class

 echo $this-driver-prop1 ;
 echo $this-driver-function1 ;
 }

   // Report non-generic errors from the selected driver

 function errors {
 }
 function debug {
 }

 ...

 }

 $gen = new generic(MySQL) ;

 // Instantiate the generic database object, which // determines its 
 own driver

 $gen-driver-prop1 = fooey

 // but they fail from here

 echo $gen-driver-prop1 ;
 echo $gen-driver-function1 ;

 // this works ok though, so everything is created // correctly

 $gen-authenticate() ;


 So I want to access generic functions as $generic-authenticate(), and 
 database specific functions $generic-driver-runquery. This allows 
 the top level code to be able to be completely generic and not know 
 anything about the underlying database.

 But I can't ! I can't find a way of accessing the encapsulated object
 (driver) from the instantiator of generic. Is it possible ?

 I guess there are lots of workaround ways. I could write lots of 
 middleman code in generic and use things like __set and __get etc 
 but its lots of extra overhead. I also know I could use extends but 
 that makes the code the wrong way around (MySQL_Driver would have to 
 extend generic), hence the top-level application would have to include 
 code to determine which driver to create rather than the db object 
 determining its own connection driver to use. This is true also for 
 just lumping everything in a single class per db type.

 Surely it must be possible ? Or am I missing something ?

 I also don't really get the idea of interface and abstract classes ?
 They
 don't seem to be any practical use ? Maybe that's me ? Anyway, not 
 really relevant to this post ...

 Please, please can someone help !!

 Thanks

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

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




--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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

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



Re: [PHP] PHP5 TUTORIAL

2007-06-27 Thread Yashesh Bhatia

hello, other interesting articles to give a bird's eye view of new
features for php5

http://www.onlamp.com/pub/a/php/2004/07/15/UpgradePHP5.html
http://devzone.zend.com/node/view/id/1714
http://www.devshed.com/c/a/PHP/Whats-New-in-PHP-5/

hth.

yashesh bhatia.


On 6/26/07, Preethi [EMAIL PROTECTED] wrote:



Hi,
Need to have a kick start on PHP5.
Kindly suggest me the good online tutorial for PHP5.
Am already working on php4.
Need to migrate from php4 to php5.

Regards,
Preethi.

Extn No: 4099

Some of the greatest science comes from those unaware of established rules
and theories.






--

Go Pre
http://www2.localaccess.com/rlalonde/pre.htm


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



Re: [PHP] PHP5 TUTORIAL

2007-06-26 Thread php-ml
Hi Preethi


 Kindly suggest me the good online tutorial for PHP5.
 Am already working on php4.
 Need to migrate from php4 to php5.

i think this is very important for OOP:

http://www.php.net/manual/en/language.oop5.php

and this one:

http://www.php.net/manual/en/language.exceptions.php


regards,
Hagen

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



Re: [PHP] PHP5 TUTORIAL

2007-06-26 Thread Nathan Nobbe

if you want to spend a little i would recommend this book from php|arch

http://www.phparch.com/shop_product.php?itemid=135

-nathan

On 6/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


Hi Preethi


 Kindly suggest me the good online tutorial for PHP5.
 Am already working on php4.
 Need to migrate from php4 to php5.

i think this is very important for OOP:

http://www.php.net/manual/en/language.oop5.php

and this one:

http://www.php.net/manual/en/language.exceptions.php


regards,
Hagen

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




Re: [PHP] PHP5 or PHP4 this is the question

2007-06-10 Thread Larry Garfield
On Saturday 09 June 2007, Robert Cummings wrote:
 On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote:
  You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.

 Must be a zombie then because I see it running almost EVERYWHERE.

Yep, it is.  PHP 4 is trying to eat your brains.  BRINS!

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-10 Thread Tijnema

On 6/10/07, Larry Garfield [EMAIL PROTECTED] wrote:

On Saturday 09 June 2007, Robert Cummings wrote:
 On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote:
  You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.

 Must be a zombie then because I see it running almost EVERYWHERE.

Yep, it is.  PHP 4 is trying to eat your brains.  BRINS!


PHP4 Zombie attack!!


--
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]  ICQ: 6817012

If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it.  -- Thomas
Jefferson

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




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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-10 Thread Robert Cummings
On Sun, 2007-06-10 at 11:01 -0500, Larry Garfield wrote:
 On Saturday 09 June 2007, Robert Cummings wrote:
  On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote:
   You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.
 
  Must be a zombie then because I see it running almost EVERYWHERE.
 
 Yep, it is.  PHP 4 is trying to eat your brains.  BRINS!

Not mine... I'm a level 60 Necromancer :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-10 Thread tedd

At 10:05 PM -0400 6/9/07, Robert Cummings wrote:

On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote:

 You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.


Must be a zombie then because I see it running almost EVERYWHERE.

Cheers,
Rob.



Rob:

You raise an excellent and obvious point. There are significant 
differences between 4 and 5 and if we are to code for clients who are 
still in 4, then using 5 routines won't work. For those clients, we 
must either dumb-down or get them to smarten-up. Considering that I 
never get anyone to do anything, I know where that leaves me.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-10 Thread Larry Garfield
On Sunday 10 June 2007, tedd wrote:
 At 10:05 PM -0400 6/9/07, Robert Cummings wrote:
 On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote:
   You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.
 
 Must be a zombie then because I see it running almost EVERYWHERE.
 
 Cheers,
 Rob.

 Rob:

 You raise an excellent and obvious point. There are significant
 differences between 4 and 5 and if we are to code for clients who are
 still in 4, then using 5 routines won't work. For those clients, we
 must either dumb-down or get them to smarten-up. Considering that I
 never get anyone to do anything, I know where that leaves me.

Actually, several open source projects are trying to band together to push for 
PHP 5 compatibility.  We're still in early stages, but if you work on an open 
source project and are interested in joining together on this, contact me off 
list. :-)

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread Robert Cummings
On Sat, 2007-06-09 at 11:59 -0700, elk dolk wrote:
 Hi all,
 After designing and testing my web pages in PHP 5.2.1   I learned 
 that  our web server has PHP 4.4.1   and I have to rollback to version 4 ! . 
 There is no OO implementation like classes or objects in my scripts but every 
 page has some queries the question is : will my scripts work in PHP 4 ? or 
 should I re-write all of them? or will it affect the speed of queries?

Should work mostly fine. PHP5 mostly brought OOP features to the table.
Since you say you didn't use any OOP, then you just need to be wary of
the odd PHP5 only function.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread Richard Lynch
On Sat, June 9, 2007 1:59 pm, elk dolk wrote:
 After designing and testing my web pages in PHP 5.2.1   I
 learned that  our web server has PHP 4.4.1   and I have to
 rollback to version 4 ! . There is no OO implementation like
 classes or objects in my scripts but every page has some
 queries the question is : will my scripts work in PHP 4 ? or
 should I re-write all of them? or will it affect the speed of
 queries?

If there's no OO and you haven't used simpleXML or the fancy SOAP
stuff, then it will probably work fine in PHP 4.

Actually, it will probably work fine in PHP 3 too, for that matter...

:-)

The queries working or not working is dependent on the database
version, not PHP.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread Tijnema

On 6/9/07, elk dolk [EMAIL PROTECTED] wrote:

Hi all,
   After designing and testing my web pages in PHP 5.2.1   I learned that  
our web server has PHP 4.4.1   and I have to rollback to version 4 ! . There is 
no OO implementation like classes or objects in my scripts but every page has 
some queries the question is : will my scripts work in PHP 4 ? or should I 
re-write all of them? or will it affect the speed of queries?

 Thank you

Put them on the site, see if it's missing functions, if so, go to the
manual page of the function and take a look at the comments, mostly
there's a PHP4 replacer described.

Tijnema

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread tedd

At 3:27 PM -0400 6/9/07, Robert Cummings wrote:

On Sat, 2007-06-09 at 11:59 -0700, elk dolk wrote:

 Hi all,
 After designing and testing my web pages in PHP 5.2.1   I 
learned that  our web server has PHP 4.4.1   and I have to rollback 
to version 4 ! . There is no OO implementation like classes or 
objects in my scripts but every page has some queries the question 
is : will my scripts work in PHP 4 ? or should I re-write all of 
them? or will it affect the speed of queries?


Should work mostly fine. PHP5 mostly brought OOP features to the table.
Since you say you didn't use any OOP, then you just need to be wary of
the odd PHP5 only function.

Cheers,
Rob.



My host just upgraded from php 4 to php 5 and while I appreciate the 
upgrade, now my really exotic functions like date() throw errors -- 
duh!


Plus, none of my passwords work anymore, so I can't fit anything -- duh, again!

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread Larry Garfield
You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.  It 
hasn't had a non-security/bug release in years.  PHP 5 is 3 years old.  The 
one and only reason to care about PHP 4 at this point is if you're writing 
something that has to run on any possible cheap shared web host, and even 
many of those are starting to move to PHP 5.2.  

If you're on a shared host, get a new shared host that supports PHP 5.2.

If you're running your own server, install PHP 5.2.

If your server's sysadmin won't let you upgrade to 5.2 or won't give yo a new 
box on which to put 5.2, then get a new sysadmin because he is going to 
suffocate your development.

As to the liklihood of portability, it depends on what you've actually done.  
Anything interesting with OO starts in PHP 5, but you said you're not using 
that.  Are you passing objects (even stdClass objects)?  That changes.  Are 
you using any of the newer array handling functions, like array_combine?  PHP 
5 added a lot of them, many of which can be implemented in user-space using 
PEAR::PHP_Compat.  There are more subtle differences, too.  

So it's quite possible that if you're not doing anything exotic you can 
downgrade your script without too much trouble.  You're still better off 
doing the Internet a favor and removing one more PHP 4 server from existence.  
It will make your life easier in the long run.

On Saturday 09 June 2007, elk dolk wrote:
 Hi all,
 After designing and testing my web pages in PHP 5.2.1   I learned
 that  our web server has PHP 4.4.1   and I have to rollback to version 4 !
 . There is no OO implementation like classes or objects in my scripts but
 every page has some queries the question is : will my scripts work in PHP 4
 ? or should I re-write all of them? or will it affect the speed of queries?

   Thank you


 -
 Be a better Globetrotter. Get better travel answers from someone who knows.
 Yahoo! Answers - Check it out.


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread Robert Cummings
On Sat, 2007-06-09 at 18:10 -0400, tedd wrote:
 At 3:27 PM -0400 6/9/07, Robert Cummings wrote:
 On Sat, 2007-06-09 at 11:59 -0700, elk dolk wrote:
   Hi all,
   After designing and testing my web pages in PHP 5.2.1   I 
 learned that  our web server has PHP 4.4.1   and I have to rollback 
 to version 4 ! . There is no OO implementation like classes or 
 objects in my scripts but every page has some queries the question 
 is : will my scripts work in PHP 4 ? or should I re-write all of 
 them? or will it affect the speed of queries?
 
 Should work mostly fine. PHP5 mostly brought OOP features to the table.
 Since you say you didn't use any OOP, then you just need to be wary of
 the odd PHP5 only function.
 
 Cheers,
 Rob.
 
 
 My host just upgraded from php 4 to php 5 and while I appreciate the 
 upgrade, now my really exotic functions like date() throw errors -- 
 duh!
 
 Plus, none of my passwords work anymore, so I can't fit anything -- duh, 
 again!

:( I PHP5 proofed my stuff a long time ago for the inevitable switch. I
still code for PHP4 but I keep in mind the differences and make sure it
works both ways. Are you getting errors or warnings? Date issues sounds
like you need ot set your timezone. Did they also upgrade the MySQL
server (password issue sounds like MySQL).

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] PHP5 or PHP4 this is the question

2007-06-09 Thread Robert Cummings
On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote:
 You should get a new server that supports PHP 5.2.1.  PHP 4 is dead.

Must be a zombie then because I see it running almost EVERYWHERE.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] PHP5 oop question...

2007-05-28 Thread Stut

Andrei wrote:

Hi list,

I have a class which I use to parse simple bbcode inside some comments.
I noticed on PHP5 that scope of preg_replace function is changed
when function is called inside a class. To the point:

[CODE]
class PHS_editor
{
...

function parse_content( $str = null )
{
$from_arr = array( @\[B\](.*?)\[\/[EMAIL PROTECTED],
@\[U\](.*?)\[\/[EMAIL PROTECTED], @\[I\](.*?)\[\/[EMAIL PROTECTED],
   @\[URL=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED],
   @\[IMG=([^\]]*)[EMAIL PROTECTED],
   @\[QUOTE=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED]
);

$to_arr = array( 'b\1/b', 'u\1/u', 'i\1/i',

 'a href=\1 target=_blank\2/a',

 'img src=\'.stripslashes(
\*$this-get_image_location*( '\\1' ) ).'\ border=\0\',

 'table width=\98%\ align=\center\
cellpadding=\1\ cellspacing=\0\ border=\0\ class=\form_type\.
  tr.
td class=\maintext\'.stripslashes(
\*$this-remove_mytags*( '\\2' ) ).'/td.
 /tr.
 /table'

 );

if( is_null( $str ) )
$str = $this-editor_content;
   
return preg_replace( $from_arr, $to_arr, str_replace(   , 

nbsp;, nl2br( $str ) ) );
}

...
}
[/CODE]

When it gets to parse [IMG] tags I get Fatal error: Using $this
when not in object context in  So it seems they changed the scope
for preg_replace callback functions. As this function is called inside
the method shouldn't it have the scope of the class?
Is there a workaround for this? I cannot declare a function
get_image_location which will staticly call the method bcuz I use
variables from instanced class.


How are you trying to use this class? It sounds like you're trying to 
use the method statically. When a method is called statically it does 
not have a $this.


-Stut

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



Re: [PHP] PHP5 oop question...

2007-05-28 Thread Andrei

Stut wrote:
 Andrei wrote:
 Hi list,

 I have a class which I use to parse simple bbcode inside some
 comments.
 I noticed on PHP5 that scope of preg_replace function is changed
 when function is called inside a class. To the point:

 [CODE]
 class PHS_editor
 {
 ...

 function parse_content( $str = null )
 {
 $from_arr = array( @\[B\](.*?)\[\/[EMAIL PROTECTED],
 @\[U\](.*?)\[\/[EMAIL PROTECTED], @\[I\](.*?)\[\/[EMAIL PROTECTED],
@\[URL=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED],
@\[IMG=([^\]]*)[EMAIL PROTECTED],
   
 @\[QUOTE=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED]
 );

 $to_arr = array( 'b\1/b', 'u\1/u', 'i\1/i',

  'a href=\1 target=_blank\2/a',

  'img src=\'.stripslashes(
 \*$this-get_image_location*( '\\1' ) ).'\ border=\0\',

  'table width=\98%\ align=\center\
 cellpadding=\1\ cellspacing=\0\ border=\0\ class=\form_type\.
   tr.
 td class=\maintext\'.stripslashes(
 \*$this-remove_mytags*( '\\2' ) ).'/td.
  /tr.
  /table'

  );

 if( is_null( $str ) )
 $str = $this-editor_content;
return preg_replace( $from_arr, $to_arr, str_replace(
   , 
 nbsp;, nl2br( $str ) ) );
 }

 ...
 }
 [/CODE]

 When it gets to parse [IMG] tags I get Fatal error: Using $this
 when not in object context in  So it seems they changed the scope
 for preg_replace callback functions. As this function is called inside
 the method shouldn't it have the scope of the class?
 Is there a workaround for this? I cannot declare a function
 get_image_location which will staticly call the method bcuz I use
 variables from instanced class.

 How are you trying to use this class? It sounds like you're trying to
 use the method statically. When a method is called statically it does
 not have a $this.

 -Stut

Yes, method was called staticly. Strange tho in php 4 it worked.
Thnx for enlighting me with this.

Andy

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



Re: [PHP] php5 cert

2007-05-21 Thread Richard Lynch
On Fri, May 18, 2007 4:45 pm, Greg Donald wrote:
 Anyone wanna share their insights into the php5 cert test?  The php4
 test was pretty simple for me, but that was a couple of years ago.  It
 seems there's quite a bit of new material being covered on the php5
 version.  I figure with the same number of questions, things had to
 get more general if anything, right?

Didn't take either, but surveyed a half-dozen who took it at php|tek
last week...

My basic impression was that they threw out a lot of the stupid
questions that relied on arcane knowledge or were just plain Bad Code
of nasty loops with silly breaks etc.

What got added was a lot of OOP stuff and stream stuff and...

'Course, there's more than just one test that they hand out, as I
understand it, so there are variations to it, and I had a very very
very small sample of people who I chatted with.

And none of them know for sure if they passed yet or not, really. :-)

I was busy both times the test was being administered, but would
probably fail anyway on the new features parts.  I'm pretty set in my
ways... :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] php5 cert

2007-05-21 Thread Richard Lynch
On Sun, May 20, 2007 10:14 am, Danial Rahmanzadeh wrote:
 are volcan exams really harder than actual php5 exam as phparch
 asserted?

I'm pretty sure after seeing Star Trek: Voyage Home, that Vulcan exams
are MUCH harder than the PHP 5 exam.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] php5 cert

2007-05-20 Thread Larry Garfield
Actually I found the real exam harder than the test exam.  It may have just 
been the question set I ended up with, but it was a lot more nitpicky on 
details that I rarely use in my work.

On Sunday 20 May 2007, Danial Rahmanzadeh wrote:
 are volcan exams really harder than actual php5 exam as phparch asserted?


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] php5 cert

2007-05-19 Thread Kevin Waterson
This one time, at band camp, Greg Donald [EMAIL PROTECTED] wrote:

 Anyone wanna share their insights into the php5 cert test?

As worthless as the php4 cert.

Kevin


-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



Re: [PHP] php5 cert

2007-05-19 Thread Greg Donald

On 5/19/07, Kevin Waterson [EMAIL PROTECTED] wrote:

As worthless as the php4 cert.


Mine has been very valuable to me, lots more job interviews and
freelance work compared to before I got it.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] php5 include() problem

2007-05-13 Thread Tijnema !

On 5/13/07, Al [EMAIL PROTECTED] wrote:

I've got a cgi file in my cgi-bin folder that I'm calling with include(). It 
worked with php4.

My shared host just upgraded to my server to php5.2.0 and the function doesn't 
work.  I can't tell if the problem is a
php5 or server configuration [which may have changed during the upgrade] issue.

If I call the file as a URL directly, it works.
http://www.foo.org/cgi-bin/file.cgi?dir=/testperms=0755

file.cgi chmods the designated directory's permissions.  It's a cgi with a php 
shebang #!/usr/bin/php

A simple file_exists() shows the file exists OK, TRUE.

I've tried using both syntaxes.

include(/home/foo/public_html/cgi-bin/file.cgi?dir=testperms=0755);

include(www.foo.org/cgi-bin/file.cgi?dir=testperms=0755);

Here is the error msg:
 Warning: include(/home/foo/public_html/cgi-bin/file.cgi?dir=/testperms=0755)
[function.include]: failed to open stream: No such file or directory in 
/home/foo/public_html/EditPage/cgi_file_test.php
on line 15

Bottom line:  It appears include() is not working right, for whatever reason.

Anyone have any ideas?

Thanks, Al



What the heck are you trying to do?
You want the cgi file to be executed? Or is there PHP code in the cgi file?
If you want the first, you should look at exec() or system() or such.
If there's PHP code, there's no sense in passing variables to the CGI
script, and if you remove the variables it will work.

Tijnema

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



Re: [PHP] php5 include() problem

2007-05-13 Thread Myron Turner

Tijnema ! wrote:

On 5/13/07, Al [EMAIL PROTECTED] wrote:
I've got a cgi file in my cgi-bin folder that I'm calling with 
include(). It worked with php4.


My shared host just upgraded to my server to php5.2.0 and the 
function doesn't work.  I can't tell if the problem is a
php5 or server configuration [which may have changed during the 
upgrade] issue.


If I call the file as a URL directly, it works.
http://www.foo.org/cgi-bin/file.cgi?dir=/testperms=0755

file.cgi chmods the designated directory's permissions.  It's a cgi 
with a php shebang #!/usr/bin/php


A simple file_exists() shows the file exists OK, TRUE.

I've tried using both syntaxes.

include(/home/foo/public_html/cgi-bin/file.cgi?dir=testperms=0755);

include(www.foo.org/cgi-bin/file.cgi?dir=testperms=0755);

Here is the error msg:
 Warning: 
include(/home/foo/public_html/cgi-bin/file.cgi?dir=/testperms=0755)
[function.include]: failed to open stream: No such file or directory 
in /home/foo/public_html/EditPage/cgi_file_test.php

on line 15

Bottom line:  It appears include() is not working right, for whatever 
reason.


Anyone have any ideas?

Thanks, Al



What the heck are you trying to do?
You want the cgi file to be executed? Or is there PHP code in the cgi 
file?

If you want the first, you should look at exec() or system() or such.
If there's PHP code, there's no sense in passing variables to the CGI
script, and if you remove the variables it will work.

Tijnema


See the examples on this page:  http://ca.php.net/include/
What you probably want to do is to change the cgi script to php and then 
give the full url, incuding http.


--

_
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

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



Re: [PHP] php5 include() problem

2007-05-13 Thread Richard Davey

Al wrote:

I've got a cgi file in my cgi-bin folder that I'm calling with 
include(). It worked with php4.


My shared host just upgraded to my server to php5.2.0 and the function 
doesn't work.  I can't tell if the problem is a php5 or server 
configuration [which may have changed during the upgrade] issue.


If I call the file as a URL directly, it works.
http://www.foo.org/cgi-bin/file.cgi?dir=/testperms=0755


Check if the new configuration of PHP allows HTTP calls. Include, 
require, fopen, etc are traditionally for local file-system files. 
Obviously you're calling it via HTTP so you get the parsed output and 
not the source code of the CGI script, but if your host has disabled URL 
opens with PHP 5 then it would explain why it no longer works.


Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] php5 include() problem

2007-05-13 Thread Al

Is there an alternate way to execute a php in cgi-bin so it can do a chmod() on site 
directories as the owner?

My approach was the only way I could think of.  Given the obvious problem(s), 
it appears that it may not be a good choice.


Richard Davey wrote:

Al wrote:

I've got a cgi file in my cgi-bin folder that I'm calling with 
include(). It worked with php4.


My shared host just upgraded to my server to php5.2.0 and the function 
doesn't work.  I can't tell if the problem is a php5 or server 
configuration [which may have changed during the upgrade] issue.


If I call the file as a URL directly, it works.
http://www.foo.org/cgi-bin/file.cgi?dir=/testperms=0755


Check if the new configuration of PHP allows HTTP calls. Include, 
require, fopen, etc are traditionally for local file-system files. 
Obviously you're calling it via HTTP so you get the parsed output and 
not the source code of the CGI script, but if your host has disabled URL 
opens with PHP 5 then it would explain why it no longer works.


Cheers,

Rich


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



Re: [PHP] php5 oop question

2007-04-12 Thread Paul Scott

On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:

 Has anybody else seen this style of syntax?
 
http://5ive.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=init_8059_1163957717userid=5729061010

I don't think that its really useful for anything, except maybe creating
overly complex SQL queries.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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

Re: [PHP] php5 oop question

2007-04-12 Thread Jim Lucas

Paul Scott wrote:

On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:


Has anybody else seen this style of syntax?


http://5ive.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=init_8059_1163957717userid=5729061010

I don't think that its really useful for anything, except maybe creating
overly complex SQL queries.

--Paul





All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 




What about using it for math?

Here is the other example that I worked up.

plaintext?php

class Math {
function __construct() {
}
function in($num=null) {
if ( is_null($num) ) {
echo A number was not given on initialization.;
exit;
}
$this-value = $num;
return $this;
}
function out() {
echo $this-value;
}
function get() {
return $this-value;
}
function add($n) {
$this-value += $n;
return $this;
}
function subtract($n) {
$this-value -= $n;
return $this;
}
function multiply($n) {
$this-value *= $n;
return $this;
}
function divide($n) {
$this-value /= $n;
return $this;
}
}

$mObj = new Math();
$mObj-in(10)-add(90)-divide(5.3)-multiply(10)-out();

?

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



Re: [PHP] php5 oop question

2007-04-12 Thread Jim Lucas

Paul Scott wrote:

On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:


Has anybody else seen this style of syntax?


http://5ive.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=init_8059_1163957717userid=5729061010

I don't think that its really useful for anything, except maybe creating
overly complex SQL queries.

--Paul





All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 



well, I guess the better question is, is why when I talk others about oop, they say that this style 
of syntax is OOP, and anything else is not.


be it dot notation or the pointers (-) in php.

I heard it called messaging at one point in the past.

the passing up of information in the tree.

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



Re: [PHP] php5 oop question

2007-04-12 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-04-11 23:36:56 -0700:
 Paul Scott wrote:
 On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:
 Has anybody else seen this style of syntax?

 I don't think that its really useful for anything, except maybe creating
 overly complex SQL queries.

 What about using it for math?

 class Math {
   function __construct() {
   }
   function in($num=null) {
   if ( is_null($num) ) {
   echo A number was not given on initialization.;
   exit;
   }
   $this-value = $num;
   return $this;
   }
   function out() {
   echo $this-value;
   }
   function get() {
   return $this-value;
   }
   function add($n) {
   $this-value += $n;
   return $this;
   }
   function subtract($n) {
   $this-value -= $n;
   return $this;
   }
   function multiply($n) {
   $this-value *= $n;
   return $this;
   }
   function divide($n) {
   $this-value /= $n;
   return $this;
   }
 }
 
 $mObj = new Math();
 $mObj-in(10)-add(90)-divide(5.3)-multiply(10)-out();

The class really represents a number, not Math, that's too abstract
(pun intended) for an instantiable class.

Besides, you're mixing together two responsibilities, Math should really
be called Number, it should be immutable, and you'll spare someone from
a terrible debugging session caused by someone doing

$math = new math;
$ten = $math-in(10);
$five = $ten-subtract(5);
$fifty = $ten-add(40);

($fifty is actually 45, because $ten is 5 after the subtract() call)

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] php5 oop question

2007-04-12 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-04-11 23:44:16 -0700:
 Paul Scott wrote:
 On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:
 
 Has anybody else seen this style of syntax?
 
 http://5ive.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=init_8059_1163957717userid=5729061010
 
 I don't think that its really useful for anything, except maybe creating
 overly complex SQL queries.

 well, I guess the better question is, is why when I talk others about oop, 
 they say that this style of syntax is OOP, and anything else is not.
 
*What* style of syntax?  Syntax is grammar, a set of rules, the
visible part of a programming language, something you either follow or
you get a parse error.  To which grammar are you referring?

 be it dot notation or the pointers (-) in php.
 
Having primitive types, including literals, behave like instances
of a class helps writing object-oriented code, because you don't have
to special case.  It's not required, however.  You can write o-o code
in today's PHP, it just won't be purely objective.

 I heard it called messaging at one point in the past.
 
 the passing up of information in the tree.

Different people use different metaphors.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] php5 oop question

2007-04-12 Thread Tim Stiles
I've seen it referred to as a Fluent Interface.  I built one just  
to see how hard it was, using a standard problem: data validation.   
The results were promising.


I combined it with an object designed to work as a factory for an  
internally stored decorator pattern.


Class Input was the factory, with a private property to hold the  
decorator object in question and a method for adding Decorators to  
the stored object based on a simple switch command.
Class Checker was the root class of the decorator pattern, doing  
nothing but returning TRUE on its check() method.
Decorator Classes for Checker included IntegerChecker,  
NumericChecker, NonEmptyChecker, RegExpChecker, EmailChecker, etc.  
etc.  All of which extended Checker, have their own custom check()  
method and a property to store the Decorator object which they wrap.


Each Checker applies its check(X) method first, then passing a  
successful request along to the Decorator object they store.  Input  
has a check() method that just passes the request along to its stored  
Decorator object.


By using the Fluent style of interface, the end result was

?php
$_input = new Input();

$_input-addCheck('Integer')
-addCheck('Range',3,9)
-addCheck('NonEmpty');

echo ($input-check('4.734'))? 'Pass': 'Fail';
?

It returns 'Fail'.  Why? It passed the NonEmpty test, passed the  
Range test, failed the Integer test.


print_r of $input object:
Input Object
(
[_checker:private] = NonEmptyChecker Object
(
[_checker:private] = RangeChecker Object
(
[_checker:private] = IntegerChecker 
Object
(
[_checker:private] = 
Checker Object
(
)
)
[_min] = 3
[_max] = 9
)
)
)

Validation works from the outside in, responses are passed from the  
inside out, so on first failure, the validation process bails.


I loop through an array of prepared Input objects for validating the  
supplied Post values from a form and get back a simple pass/fail  
response for each.


A bit of work to set up initially, but once the system is built, it's  
pretty elegant.


Tim Stiles
Icomex.com,
DallasPHP.org


On Apr 12, 2007, at 1:29 AM, Paul Scott wrote:



On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:


Has anybody else seen this style of syntax?

http://5ive.uwc.ac.za/index.php? 
module=blogaction=viewsinglepostid=init_8059_1163957717userid=57290 
61010


I don't think that its really useful for anything, except maybe  
creating

overly complex SQL queries.

--Paul

All Email originating from UWC is covered by disclaimer http:// 
www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm


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


Tim Stiles,
WatchMaker,
Icomex.com




Re: [PHP] php5 oop question

2007-04-12 Thread Tim Stiles
I suppose I should have summarized what I learned from that  
experiment, putting myself more squarely on topic:  Simply put, a  
Fluent interface let me move from


$_input-addCheck('Integer');
$_input-addCheck('Range',3,9);
$_input-addCheck('NonEmpty');

to

$_input-addCheck('Integer')
-addCheck('Range',3,9)
-addCheck('NonEmpty');

with almost no effort.  Not a huge timesaver, but I kept it in  
because I find the necessary code that I'll use repeatedly to be less  
cluttered and easier to read.  Less experienced developers who will  
have to work with my code felt the same way.  It just feels like less  
labor.  And as a solution, it suited this problem well, mirroring how  
most people mentally approached the issue - making it easier for them  
to understand the code at a glance.


I elaborated on that problem because it was specifically the nature  
of the problem that led me to Fluent interfaces as being part of the  
solution.  I needed to set up a complex configuration within the  
object, but needed only a very simple response from it.  Like others  
pointed out, a SQL query is a very simple thing, but building one may  
involve many seemingly simple steps that occur in no prescribed  
particular order, and you don't need the result until the  
configuration is complete.  Fluent interfaces can hide complexity.




1) Fluent interfaces seem to work best when most of your methods  
alter the internal characteristics of an object. Setting properties,  
not Getting them.  You can't really use a fluent interface when you  
actually NEED a specific response from your method: they work by  
returning a reference to the object itself instead of returning a  
value - that way, the response they deliver is set up and ready to  
receive a new, unrelated method call.  You can combine the fluent  
with the conventional, but then you have to remember that any non- 
fluent call must occur last in a string of requests.  I could have  
easily written:


$test = $_input-addCheck('Integer')
-addCheck('Range',3,9)
-addCheck('NonEmpty')
-check('4.97');
if($test)? ...

but I found it more legible to stay conventional when using non- 
fluent methods.


Basically, if you have configuration processes that often need to be  
called sequentially, but not always in the same sequence, Fluent  
interfaces can smooth the rough edges.




2) Fluent interfaces probably work better with thrown exceptions than  
they do with error notices.  If you generate a non-fatal error in the  
middle of a string of fluent method calls, how do you cope with it?   
Return the object anyway and let the next method continue? Not return  
the object and get a new error because your error message can't  
accept a method call?  Bail out at the point of error within your  
method instead of pointing where the error was caused?  Exceptions  
move the error handling outside of the predicted flow of the fluent  
interface, making them easier to deal with.  Your errors represent  
what actually went wrong instead of being a side-effect or symptom of  
something that went wrong earlier in the process.



To sum up, Fluent interfaces seem to be a great solution when  
combined with a certain set of well-defined problems and practices.   
PHP5 makes them even more useful.  They save some keystrokes, they  
can improve code legibility, they can make PHP code more intuitive  
for people who weren't the ones who created it.  I don't think they  
make code execution any faster (or slower, for that matter).  It's  
worth knowing about them, but they probably shouldn't change your day  
to day practices.  As with most techniques, it becomes a matter of  
knowing when to apply this particular tool.


Tim Stiles,
WatchMaker,
Icomex.com
DallasPHP.org

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



Re: [PHP] php5 oop question

2007-04-12 Thread Jochem Maas
nice write up. :-)

Tim Stiles wrote:
 I suppose I should have summarized what I learned from that experiment,
 putting myself more squarely on topic:  Simply put, a Fluent interface
 let me move from
 

/snip

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



Re: [PHP] php5 oop question

2007-04-12 Thread Richard Lynch
a) I don't see how the part about the dot notation has anything to
do with the class presetned

b) I don't see any benefit to the class presented

c) Trying to follow the chain of - operators and method calls just
gave me a headache.

Other than that, it's really nifty. :-v

On Thu, April 12, 2007 1:22 am, Jim Lucas wrote:
 Ok, I have seen many different examples of OOP, but nothing quite like
 this.

 Someone was showing me syntax for Ruby the other day, and it got me
 thinking, wouldn't it be neat to
 imitate ruby, or be it a little more generic, dot notation for OOP
 ways of calling methods like
 Java, javascript, ruby and others.  So I came up with this.

 Seems to work in PHP5, but chokes in PHP4.

 I would like input on this setup for calling methods.

 plaintext?php

 class myString {
   private $value = '';
   function __construct() {
   }
   function in($str=null) {
   if ( is_null($str) ) {
   echo A string wasn't given.;
   exit;
   }
   $this-value = $str;
   $this-setProperties();
   return $this;
   }
   function out() {
   echo $this-value;
   }
   function get() {
   return $this-value;
   }
   function append($a) {
   $this-value = $this-value.$a;
   $this-setProperties();
   return $this;
   }
   function prepend($a) {
   $this-value = $a.$this-value;
   $this-setProperties();
   return $this;
   }
   function regex_replace($from, $to) {
   $this-value = preg_replace(!{$from}!, $to, $this-value);
   $this-setProperties();
   return $this;
   }
   function setProperties() {
   $this-str_length = strlen($this-value);
   return $this;
   }
   function length() {
   return $this-str_length;
   }
 }

 $str = new myString;

 echo $str-in(Starting String!)-prepend(Second
 String!)-regex_replace(' ', '_')-get();
 echo $str-length();
 $str-in(A new string)-out();

 ?

 Has anybody else seen this style of syntax?

 Have they used this style of syntax?

 If so, what is your opinion of this style?

 TIA
 Jim

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] php5 oop question

2007-04-12 Thread Larry Garfield
I have never heard that described as a fluent interface before, but you'd 
probably like jQuery. :-)  It's a javascript library that uses much the same 
concept, although it refers to it as function chaining.  It also operates 
on multiple objects simultaneously, which is even niftier.

On Thursday 12 April 2007 12:37 pm, Tim Stiles wrote:
 I suppose I should have summarized what I learned from that
 experiment, putting myself more squarely on topic:  Simply put, a
 Fluent interface let me move from

 $_input-addCheck('Integer');
 $_input-addCheck('Range',3,9);
 $_input-addCheck('NonEmpty');

 to

 $_input-addCheck('Integer')
   -addCheck('Range',3,9)
   -addCheck('NonEmpty');

 with almost no effort.  Not a huge timesaver, but I kept it in
 because I find the necessary code that I'll use repeatedly to be less
 cluttered and easier to read.  Less experienced developers who will
 have to work with my code felt the same way.  It just feels like less
 labor.  And as a solution, it suited this problem well, mirroring how
 most people mentally approached the issue - making it easier for them
 to understand the code at a glance.

 I elaborated on that problem because it was specifically the nature
 of the problem that led me to Fluent interfaces as being part of the
 solution.  I needed to set up a complex configuration within the
 object, but needed only a very simple response from it.  Like others
 pointed out, a SQL query is a very simple thing, but building one may
 involve many seemingly simple steps that occur in no prescribed
 particular order, and you don't need the result until the
 configuration is complete.  Fluent interfaces can hide complexity.



 1) Fluent interfaces seem to work best when most of your methods
 alter the internal characteristics of an object. Setting properties,
 not Getting them.  You can't really use a fluent interface when you
 actually NEED a specific response from your method: they work by
 returning a reference to the object itself instead of returning a
 value - that way, the response they deliver is set up and ready to
 receive a new, unrelated method call.  You can combine the fluent
 with the conventional, but then you have to remember that any non-
 fluent call must occur last in a string of requests.  I could have
 easily written:

 $test = $_input-addCheck('Integer')
   -addCheck('Range',3,9)
   -addCheck('NonEmpty')
   -check('4.97');
 if($test)? ...

 but I found it more legible to stay conventional when using non-
 fluent methods.

 Basically, if you have configuration processes that often need to be
 called sequentially, but not always in the same sequence, Fluent
 interfaces can smooth the rough edges.



 2) Fluent interfaces probably work better with thrown exceptions than
 they do with error notices.  If you generate a non-fatal error in the
 middle of a string of fluent method calls, how do you cope with it?
 Return the object anyway and let the next method continue? Not return
 the object and get a new error because your error message can't
 accept a method call?  Bail out at the point of error within your
 method instead of pointing where the error was caused?  Exceptions
 move the error handling outside of the predicted flow of the fluent
 interface, making them easier to deal with.  Your errors represent
 what actually went wrong instead of being a side-effect or symptom of
 something that went wrong earlier in the process.


 To sum up, Fluent interfaces seem to be a great solution when
 combined with a certain set of well-defined problems and practices.
 PHP5 makes them even more useful.  They save some keystrokes, they
 can improve code legibility, they can make PHP code more intuitive
 for people who weren't the ones who created it.  I don't think they
 make code execution any faster (or slower, for that matter).  It's
 worth knowing about them, but they probably shouldn't change your day
 to day practices.  As with most techniques, it becomes a matter of
 knowing when to apply this particular tool.

 Tim Stiles,
 WatchMaker,
 Icomex.com
 DallasPHP.org

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP5 Commercial Development

2007-02-09 Thread Jochem Maas
Ligaya A. Turmelle wrote:
 Law of mass tonnage - better to be in the big motorized vehicle then the
 little one when *crunch* happens.

and especially not under it as Richard pointed out. :-/

 
 Respectfully,
 Ligaya Turmelle
 Systems Analyst
 Guamcell Communications
 Phone: (671)689-2377 
 -Original Message-
 From: Stut [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, February 06, 2007 2:55 AM
 To: tedd
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] PHP5  Commercial Development
 
 tedd wrote:
 At 12:06 AM -0500 2/5/07, Craige Leeder wrote:
 PHP is fine for commercial environments. Many people are just afraid 
 of it due to the fact it is known to break some poorly written PHP 4 
 scripts, and the fact that many people don't think it's new features 
 are necessary. It is perfectly fine to use it in a commercial 
 environment however.
 I feel the same way about cars. There are some terrible drivers out 
 there, so we should all take the bus.
 
 Won't work. There are some *really* terrible bus drivers out there.
 
 -Stut
 
 --
 PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
 http://www.php.net/unsub.php
 

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



Re: [PHP] PHP5 Commercial Development

2007-02-07 Thread Lars Gunther

Robert Cummings skrev:

On Tue, 2007-02-06 at 23:45 +0100, Keryx Web wrote:
Could you point out to me where exactly the discussion became about PHP4
versus PHP5? I seem to be smelling the red herring technique of changing
the conversation focus so as to inappropriately lend credence to the
initial argument because the secondary red herring argument can be
argued more in your favour despite its irrelevance.


The thread was started by Eric Gorr who wrote:

blockquoteI haven't tracked this particular issue, but I know when 
PHP5 was first released is wasn't recommended in a commercial/production 
environment. However, a lot of time has passed and we're at v5.2 
now...have things changed? Have GoogleYahoo, for example, moved to 
PHP5? Or is PHP4 still the recommendation for such environments? 
/blockquote


Since I am unaware of what version of PHP Yahoo mainly uses (I've heard 
some of their developers talk, and they use PHP 5) and since Google 
seems to be a Java shop, I took the liberty of giving my oiwn view of 
why PHP should be used for professional development.


And I said that for reasons of security and performance prepared 
statements usually are the best way of interacting with a DBMS. To me 
they are the main reason why I shun PHP 4 when developing new apps.


Other things I personally like about PHP 5:
- The OO model.
- Tidy 2.0
- All things XML (Simple, DOM, Reader, now also Writer, etc)
- Assign by reference in foreach loops

Can a professional app be developed without these? Probably, but why 
limit your arsenal?



Lars Gunther

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



Re: [PHP] PHP5 Commercial Development

2007-02-07 Thread Robert Cummings
On Wed, 2007-02-07 at 09:47 +0100, Lars Gunther wrote:
 Robert Cummings skrev:
  On Tue, 2007-02-06 at 23:45 +0100, Keryx Web wrote:
  Could you point out to me where exactly the discussion became about PHP4
  versus PHP5? I seem to be smelling the red herring technique of changing
  the conversation focus so as to inappropriately lend credence to the
  initial argument because the secondary red herring argument can be
  argued more in your favour despite its irrelevance.
 
 The thread was started by Eric Gorr who wrote:
 
 blockquoteI haven't tracked this particular issue, but I know when 
 PHP5 was first released is wasn't recommended in a commercial/production 
 environment. However, a lot of time has passed and we're at v5.2 
 now...have things changed? Have GoogleYahoo, for example, moved to 
 PHP5? Or is PHP4 still the recommendation for such environments? 
 /blockquote

Ah, quite true, though our particular branch wasn't about this :)

 Since I am unaware of what version of PHP Yahoo mainly uses (I've heard 
 some of their developers talk, and they use PHP 5) and since Google 
 seems to be a Java shop, I took the liberty of giving my oiwn view of 
 why PHP should be used for professional development.
 
 And I said that for reasons of security and performance prepared 
 statements usually are the best way of interacting with a DBMS. To me 
 they are the main reason why I shun PHP 4 when developing new apps.
 
 Other things I personally like about PHP 5:
 - The OO model.
 - Tidy 2.0
 - All things XML (Simple, DOM, Reader, now also Writer, etc)
 - Assign by reference in foreach loops
 
 Can a professional app be developed without these? Probably, but why 
 limit your arsenal?

You make a decent point, but then, due to the Turing complete nature of
languages anything PHP5 can do PHP4 can also do. And since PHP5 has a
smaller adoption arena and PHP5 can with run PHP4 apps (with some
attention to detail), why limit your audience?

As you can see, there are pros and cons to either decision and much
depends on your focus.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] PHP5 Commercial Development

2007-02-06 Thread Keryx Web

Robert Cummings skrev:

I sincerely question the competence of someone who advocates a one size
fits all approach to programming. There are many reasons why a developer
may work with the old-school interface calls. For instance they may be
supporting an old school application. They might be writing their own
abstract layer. They might be optimizing an extremely loaded system
whereby explicitly using the API calls improves speed. Prepared
statements only improve speed when making multiple queries to the
database having the same format. They slow things down when making
unique queries. Any developer worth his salt doesn't need prepared
statements to improve security, and assuming prepared statements will
protect you is silly since they cannot protect against everything. A
professional knows when to use any given approach given the environment
and requirements.

Cheers,
Rob.


So I was perhaps a bit inflammatory in my post. But I do not see myself 
completely rebutted.


1. Maintaining legacy apps does not fall under the categories I was 
referring to. If you are bound by legacy constraints it is another ballgame.


2. In a short mail like this one there is not room to expand every 
minute detail. I do realise that PDO is not the best way to go for every 
app. But in saying that prepared statements is a really good way to 
protect against SQL-injection, I'm just echoing Ilia Alshanetsky 
(spelling?) and a few other rather renowned security experts. Of course 
one should always have a defense in depth, though.


3. Speed loss from prepared statements are usually negligible even for a 
single query. There are tests published on the net. And if one wants 
speed, one should probably consider a caching layer between PHP and ones 
DBMS. The OO-model in PHP 5 would make such multi tiered apps simpler to 
develop as well.


The question PHP 4 or PHP 5: If you stay with 4 you are bound to a one 
size fits all solution. In PHP 5 you can use DB-specific drivers or PDO 
or a PHP-based abstraction layer. That's *more* choice, not less!


To summarize: With PDO or mysqli I can use both old school SQL and 
prepared statements, in PHP 4 there are fewer options! My case for PHP 5 
stands intact.


And finally: With each new release of PHP we can expect improvements in 
PDO, making it a more future safe alternative.



Lars Gunther

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



Re: [PHP] PHP5 Commercial Development

2007-02-06 Thread Robert Cummings
On Tue, 2007-02-06 at 23:45 +0100, Keryx Web wrote:

 The question PHP 4 or PHP 5: If you stay with 4 you are bound to a one 
 size fits all solution. In PHP 5 you can use DB-specific drivers or PDO 
 or a PHP-based abstraction layer. That's *more* choice, not less!
 
 To summarize: With PDO or mysqli I can use both old school SQL and 
 prepared statements, in PHP 4 there are fewer options! My case for PHP 5 
 stands intact.
 
 And finally: With each new release of PHP we can expect improvements in 
 PDO, making it a more future safe alternative.

Could you point out to me where exactly the discussion became about PHP4
versus PHP5? I seem to be smelling the red herring technique of changing
the conversation focus so as to inappropriately lend credence to the
initial argument because the secondary red herring argument can be
argued more in your favour despite its irrelevance.

http://en.wikipedia.org/wiki/Red_herring

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] PHP5 Commercial Development

2007-02-06 Thread Ligaya A. Turmelle
Law of mass tonnage - better to be in the big motorized vehicle then the
little one when *crunch* happens.

Respectfully,
Ligaya Turmelle
Systems Analyst
Guamcell Communications
Phone: (671)689-2377 
-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 06, 2007 2:55 AM
To: tedd
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP5  Commercial Development

tedd wrote:
 At 12:06 AM -0500 2/5/07, Craige Leeder wrote:
 PHP is fine for commercial environments. Many people are just afraid 
 of it due to the fact it is known to break some poorly written PHP 4 
 scripts, and the fact that many people don't think it's new features 
 are necessary. It is perfectly fine to use it in a commercial 
 environment however.
 
 I feel the same way about cars. There are some terrible drivers out 
 there, so we should all take the bus.

Won't work. There are some *really* terrible bus drivers out there.

-Stut

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

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread tedd

At 12:06 AM -0500 2/5/07, Craige Leeder wrote:

Eric,

PHP is fine for commercial environments. Many people are just afraid
of it due to the fact it is known to break some poorly written PHP 4
scripts, and the fact that many people don't think it's new features
are necessary. It is perfectly fine to use it in a commercial
environment however.

- Craige


I feel the same way about cars. There are some terrible drivers out 
there, so we should all take the bus.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread Stut

tedd wrote:

At 12:06 AM -0500 2/5/07, Craige Leeder wrote:

PHP is fine for commercial environments. Many people are just afraid
of it due to the fact it is known to break some poorly written PHP 4
scripts, and the fact that many people don't think it's new features
are necessary. It is perfectly fine to use it in a commercial
environment however.


I feel the same way about cars. There are some terrible drivers out 
there, so we should all take the bus.


Won't work. There are some *really* terrible bus drivers out there.

-Stut

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread Keryx Web

Eric Gorr skrev:
I haven't tracked this particular issue, but I know when PHP5 was first 
released is wasn't recommended in a commercial/production environment. 
However, a lot of time has passed and we're at v5.2 now...have things 
changed? Have GoogleYahoo, for example, moved to PHP5? Or is PHP4 still 
the recommendation for such environments?


My two cents: Any modern PHP-app should use prepared statements for 
efficiency and security. PEAR-DB and some other PHP 4 workable 
abstraction layers can emulate this, but it's only in PHP 5 you get the 
real thing, with mysqli or PDO, or a PHP class that's built on top of 
such an interface.


To me, that's the must have feature of PHP 5 I can't be without. Nor do 
I think one could call him-/herself professional still doing old school 
mysql-interface calls to the DBMS.



Lars Gunther

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread Robert Cummings
On Mon, 2007-02-05 at 22:00 +0100, Keryx Web wrote:
 Eric Gorr skrev:
  I haven't tracked this particular issue, but I know when PHP5 was first 
  released is wasn't recommended in a commercial/production environment. 
  However, a lot of time has passed and we're at v5.2 now...have things 
  changed? Have GoogleYahoo, for example, moved to PHP5? Or is PHP4 still 
  the recommendation for such environments?
 
 My two cents: Any modern PHP-app should use prepared statements for 
 efficiency and security. PEAR-DB and some other PHP 4 workable 
 abstraction layers can emulate this, but it's only in PHP 5 you get the 
 real thing, with mysqli or PDO, or a PHP class that's built on top of 
 such an interface.
 
 To me, that's the must have feature of PHP 5 I can't be without. Nor do 
 I think one could call him-/herself professional still doing old school 
 mysql-interface calls to the DBMS.

I sincerely question the competence of someone who advocates a one size
fits all approach to programming. There are many reasons why a developer
may work with the old-school interface calls. For instance they may be
supporting an old school application. They might be writing their own
abstract layer. They might be optimizing an extremely loaded system
whereby explicitly using the API calls improves speed. Prepared
statements only improve speed when making multiple queries to the
database having the same format. They slow things down when making
unique queries. Any developer worth his salt doesn't need prepared
statements to improve security, and assuming prepared statements will
protect you is silly since they cannot protect against everything. A
professional knows when to use any given approach given the environment
and requirements.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread Jochem Maas
Stut wrote:
 tedd wrote:
 At 12:06 AM -0500 2/5/07, Craige Leeder wrote:
 PHP is fine for commercial environments. Many people are just afraid
 of it due to the fact it is known to break some poorly written PHP 4
 scripts, and the fact that many people don't think it's new features
 are necessary. It is perfectly fine to use it in a commercial
 environment however.

 I feel the same way about cars. There are some terrible drivers out
 there, so we should all take the bus.
 
 Won't work. There are some *really* terrible bus drivers out there.

sandra bullock.

 
 -Stut
 

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread Jochem Maas
Robert Cummings wrote:
 On Mon, 2007-02-05 at 22:00 +0100, Keryx Web wrote:
 Eric Gorr skrev:
 I haven't tracked this particular issue, but I know when PHP5 was first 
 released is wasn't recommended in a commercial/production environment. 
 However, a lot of time has passed and we're at v5.2 now...have things 
 changed? Have GoogleYahoo, for example, moved to PHP5? Or is PHP4 still 
 the recommendation for such environments?
 My two cents: Any modern PHP-app should use prepared statements for 
 efficiency and security. PEAR-DB and some other PHP 4 workable 
 abstraction layers can emulate this, but it's only in PHP 5 you get the 
 real thing, with mysqli or PDO, or a PHP class that's built on top of 
 such an interface.

 To me, that's the must have feature of PHP 5 I can't be without. Nor do 
 I think one could call him-/herself professional still doing old school 
 mysql-interface calls to the DBMS.
 
 I sincerely question the competence of someone who advocates a one size
 fits all approach to programming. There are many reasons why a developer
 may work with the old-school interface calls. For instance they may be
 supporting an old school application. They might be writing their own
 abstract layer. They might be optimizing an extremely loaded system
 whereby explicitly using the API calls improves speed. Prepared
 statements only improve speed when making multiple queries to the
 database having the same format. They slow things down when making
 unique queries. Any developer worth his salt doesn't need prepared
 statements to improve security, and assuming prepared statements will
 protect you is silly since they cannot protect against everything. A
 professional knows when to use any given approach given the environment
 and requirements.

you forgot to mention the firebird users - who have the choice of using
the 'old-school' interface (with all the kick-ass parameterized queries 
functionality
that's actually part of firebird itself, etc) or use the PDO equivelant which 
is:

a, pretty much broken for firebird.
b, emulates the superior functionality of the firebird database at the php 
level.

just my 2 old-school db calls. :-)

 
 Cheers,
 Rob.

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



Re: [PHP] PHP5 Commercial Development

2007-02-05 Thread Richard Lynch




On Mon, February 5, 2007 10:55 am, Stut wrote:
 tedd wrote:
 At 12:06 AM -0500 2/5/07, Craige Leeder wrote:
 PHP is fine for commercial environments. Many people are just
 afraid
 of it due to the fact it is known to break some poorly written PHP
 4
 scripts, and the fact that many people don't think it's new
 features
 are necessary. It is perfectly fine to use it in a commercial
 environment however.

 I feel the same way about cars. There are some terrible drivers out
 there, so we should all take the bus.

 Won't work. There are some *really* terrible bus drivers out there.

Yeah a buddy of mine got hit by a bus, and he ended up INSIDE the
wheel well wrapped around the tire before the driver actually stopped.

It was pretty ugly...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] PHP5 Commercial Development

2007-02-04 Thread Craige Leeder

Eric,

PHP is fine for commercial environments. Many people are just afraid
of it due to the fact it is known to break some poorly written PHP 4
scripts, and the fact that many people don't think it's new features
are necessary. It is perfectly fine to use it in a commercial
environment however.

- Craige

On 2/2/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Thu, February 1, 2007 5:13 pm, Eric Gorr wrote:
 I haven't tracked this particular issue, but I know when PHP5 was
 first released is wasn't recommended in a commercial/production
 environment. However, a lot of time has passed and we're at v5.2
 now...have things changed? Have GoogleYahoo, for example, moved to
 PHP5? Or is PHP4 still the recommendation for such environments?

Do you need XML processing or SOAP?

What are your performance requirements?

Are there features in Apache 2 that you need?

Are you using only PHP extensions that are known to be [probably]
thread safe?

You've grossly under-documented your needs, to the point that nobody
can answer your question very well.

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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




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



  1   2   3   4   >