simple php syntax question |
[eluser]Bogdan Tanase[/eluser]
Hi, Is it possible to write the following sequence shorter? Code: $row=$query->row(); //active record row result could I write something like Code: $name=($query->row())->name; //obviously this will not work I'd like to know if there's a way I could reference the member of the object returned by row() function without assigning it to another variable. Thank you!
[eluser]xwero[/eluser]
if you use php5 you can write Code: $name = $this->select('name')->where('id',$id)->get('table')->row()->name;
[eluser]Bogdan Tanase[/eluser]
right! Thank you xwero. I forgot all about method chaining
[eluser]jdfwarrior[/eluser]
Is that in t he documentation/user guide somewhere? Never seen it done quite like that..
[eluser]TheFuzzy0ne[/eluser]
[quote author="jdfwarrior" date="1234293610"]Is that in t he documentation/user guide somewhere? Never seen it done quite like that..[/quote] Yes it is. http://ellislab.com/codeigniter/user-gui...l#chaining |
Welcome Guest, Not a member yet? Register Sign In |