Welcome Guest, Not a member yet? Register   Sign In
Shorter way to do this ?
#1

[eluser]chefnelone[/eluser]
Hello,

I just want to know if is there a way write this in one single line:

Code:
$products = $this->db->get('products');
return $products->result();

thanks
#2

[eluser]mddd[/eluser]
Sure.
Code:
return $this->db->get('products')->result();
#3

[eluser]chefnelone[/eluser]
[quote author="mddd" date="1278599758"]Sure.
Code:
return $this->db->get('products')->result();
[/quote]

thanks mddd.
#4

[eluser]WanWizard[/eluser]
Note: PHP5 only.
#5

[eluser]wiredesignz[/eluser]
[quote author="WanWizard" date="1278607836"]Note: PHP5 only.[/quote]

So are you saying that PHP6 does not have this feature then?
#6

[eluser]Twisted1919[/eluser]
And if no result is returned ?
#7

[eluser]WanWizard[/eluser]
[quote author="wiredesignz" date="1278608433"][quote author="WanWizard" date="1278607836"]Note: PHP5 only.[/quote]
So are you saying that PHP6 does not have this feature then?[/quote]
:lol: No, I mean that CI still claims PHP4 compatibility, and that you'll lose that if you use this feature. Depending on the TS' environment that might be relevant.
#8

[eluser]Jelmer[/eluser]
[quote author="Twisted1919" date="1278617726"]And if no result is returned ?[/quote]
Code:
$products = $this->db->get('products')->result();
if (empty($products))
{
    // do something for empty condition
}
else
{
    // show the products...
}




Theme © iAndrew 2016 - Forum software by © MyBB