CodeIgniter 3.0 Proposed Change: NULL v FALSE |
[eluser]Aken[/eluser]
[quote author="Phil Sturgeon" date="1337795055"]We can add that in too, sure. empty array() is pretty weird.[/quote] For which method? result() and result_array() should still return empty arrays in my opinion.
[eluser]WanWizard[/eluser]
[quote author="Phil Sturgeon" date="1337795055"]We can add that in too, sure. empty array() is pretty weird.[/quote] I'm not entirely convinced that is the case. If you consider the fact that a resultset is returned as the result of a query, then an empty array is a perfect representation of an empty resultset. NULL would indicate there is no resultset that can be returned. So a -1 from me on this one...
[eluser]Phil Sturgeon[/eluser]
I think you guys mistook what I was planning on doing, I have no intentions of doing anything weird or stupid. Currently if there are no results (array or object) then you'll get an empty array, which is fine. But if you use the row() method, wether you are expecting an array or an object, you get an empty array. $this->db->get('foo')->row(); There is no reason that this should return array(), but it does. THAT is what I am changing, to FALSE because it is saying "Arg, no row has been found". This changing FALSE to NULL stuff is more about looking up array values and setting a reasonable default instead of FALSE, which usually ends up being 0 ![]()
[eluser]Phil Sturgeon[/eluser]
In case there is any confusion I want to make CodeIgniter do this, but right now they would both return an empty array - and that is odd!
[eluser]InsiteFX[/eluser]
Phil, I think this is assigning the return value from the CI_Loader Class library method! Code: // is assigning the value from the CI_Loader Class library - See the return values in the Loader library method. If you assign: Code: $foo = $this->table; // then it will work.
[eluser]Phil Sturgeon[/eluser]
Ignore that table stuff, that code in the image was irrelevant to this conversation and is another feature branch I have developed. What we are talking about here (now that everyone seems to have moved past the NULL / FALSE for input, session, etc) is the DB defaults. Code: public function db_test() Currently those are both returning "array()" which is stupid. Now result() will return array() and row() will return NULL.
[eluser]WanWizard[/eluser]
ihmo Code: $foo = $this->db->get('test')->result(); Code: $foo = $this->db->get('test')->row(); So +1 on that change. ![]()
[eluser]Aken[/eluser]
Agreed. That's why I asked - wanted to make sure the result sets still returned empty arrays. |
Welcome Guest, Not a member yet? Register Sign In |