[PHP] accessing magic parent set
Is this the only way to access the magic __set from the parent class: public function __set($columnName, $value) { if ($value !== $this->$columnName) { parent::__set($columnName, $value); } } I would have liked to work this way: public function __set($columnName, $value) { if ($value !== $this->$columnName) { parent::$columnName = $value; } } And another question. There is a self, a static and a parent Why is it only $this and not a $parent too?
Re: [PHP] code quest - ECHO?!?
They are almost identical. Echo supports multiple parameters like "echo $a, $b;" print is 20% slower than echo (by some tests). "echo" is shorter than "print" so it's easy to write. In fact it's all a matter of taste. The same reason we user die instead of exit. Alex On Sun, Dec 12, 2010 at 6:23 PM, Kirk Bailey wrote: > Groovy; they appear to be identical in all but name. IDENTICAL. Or am I > missing a subtle definition difference? > > > > David Robley wrote: > >> Kirk Bailey wrote: >> >> >> >>> Ok, so what is echo, and how is it different from print. >>> >>> The code in code quest used echo. I have a copy of learning php 5.0 from >>> O'Reilly, and noplace does it mention echo. Why? What's the difference? >>> IS there a difference? Is there an advantage to either? Please clarify >>> for this newbie. >>> >>> >>> >> >> The documentation says it all better than I can: >> >> http://php.net/manual/en/function.echo.php >> http://php.net/manual/en/function.print.php >> >> Cheers >> >> > > -- > end > > Very Truly yours, >- Kirk Bailey, > Largo Florida > > kniht+-+ > | BOX | +-+think >
Re: [PHP] ORM doctrine
Doctrine is mature and well I've seen it plenty of times companies using it. Of course it handles multi table joins but I think it's main purpose is not related to users writing joins... It's an ORM, you just read and write objects. Caching is something that must be there and you can read more on wiki: http://en.wikipedia.org/wiki/Doctrine_%28PHP%29 Alex On Thu, Dec 9, 2010 at 5:02 AM, Tommy Pham wrote: > Hi, > > Has anyone used doctrine before? I know Nathan mentioned it in the other > thread but I was wondering how does it handle multi table joins query, > about > its performance and whether it uses any type of caching. > > Thanks, > Tommy > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] new keyword combined with other things...
I know how to do it in other ways. I was just wondering why the simple new Object() -> method won't work. new operator has precedence over... That must be the problem. -> is not an operator. Is not in this list: http://php.net/manual/en/language.operators.precedence.php That must be done. -> should be an operator! Alex On Tue, Dec 7, 2010 at 10:49 PM, Jim Lucas wrote: > On 12/7/2010 7:40 AM, Alexandru Patranescu wrote: > > In many other languages this will work: > > > > *$result = new Object() -> method();* > > > > But in php, it fails at parsing. > > I've tried with parenthesis around new but nothing. Anyhow, as I saw > later, > > *new* operator has precedence over others so this couldn't be a solution. > > I know a static function can be defined and the above statement can > > transform into > > > > *$result = Object::getNewInstance() -> method()* > > > > but is there any way to write it directly? and if not, why isn't this > > implemented yet and when will it be? > > > > best regards, > > Patranescu Alexandru > > > > > Here is what I do if I want to make it a one liner... > > > function myNew($obj='stdClass') { >return new $obj(); > } > > class CustomClass { >function PrintString($str='Something') >{ >print($str); >} >function ReturnString($str='Something') >{ >return $str; >} > } > > > myNew('CustomClass')->PrintString(); > > echo myNew('CustomClass')->ReturnString('Something Else'); > > $var = myNew('CustomClass')->ReturnString('And again...'); > > echo $var; > > ?> > > I also use the following if I want to use the Singleton method of getting > my data. > > > class myClass { >static $_instance; >static function run($DefaultValues=null) >{ >if(self::$_instance === null) >{ >//First and only construction. >self::$_instance = new self($DefaultValues); >} >return self::$_instance; >} >function PrintString($str='Default Value') >{ >print $str; >} >function ReturnString($str='Something') >{ >return $str; >} > } > > myClass::run()->PrintString(); > > echo myClass::run()->ReturnString(); > > $var = myClass::run()->ReturnString(); > > echo $var; > > ?> > > YMMV >
[PHP] new keyword combined with other things...
In many other languages this will work: *$result = new Object() -> method();* But in php, it fails at parsing. I've tried with parenthesis around new but nothing. Anyhow, as I saw later, *new* operator has precedence over others so this couldn't be a solution. I know a static function can be defined and the above statement can transform into *$result = Object::getNewInstance() -> method()* but is there any way to write it directly? and if not, why isn't this implemented yet and when will it be? best regards, Patranescu Alexandru