• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

This is just a general PHP question...Im wondering if this would work:

$query = $this->db->get_where('portfolio', array('id' => $id), 1)  = (!$query) ? return $query->row() : return false;

Or would I have to do it this way?

$query = (!is_null($this->db->get_where('portfolio', array('id' => $id), 1))) ? return $query->row() : return false;

Thanks in advance!

[eluser]Colin Williams[/eluser]
What's the point?

If they work, they work, but I would advise against either.

well just wondering which one does...im on a really slow pc for a while and my host is down. So im just curious if anyone know if it would work...runtime wise

I think both examples don't work. If you would want to do something like that i think this is the way to go
return ($query = $this->db->get_where('portfolio', array('id' => $id), 1))? $query->row() : false;

I'm all for shortened code too, and I can understand xwero's example.

Which ever coding style you choose, just make sure it will make sense to you when you read it again in six months time.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.