Posts: 1
Threads: 0
Joined: Mar 2015
Reputation:
0
Both are good however when you use result_array() it makes the query and places it in an array and when you use result() it puts the query in a stdClass object there are these two forms because you can not return a stdClass object in a method only in the array. Sorry my english poor!
Posts: 215
Threads: 16
Joined: Oct 2014
Reputation:
10
Doesn't matter, it's up to developers preference on working with the data. I prefer array's as merging is easier but a lot of dev's prefer objects for their syntax.
Posts: 12
Threads: 0
Joined: Feb 2015
Reputation:
0
as others have said, it doesn't matter, it depends on personal choice and personal taste of syntax...
however if you are merging your results then you should prefer result_array(), but like me if you are using ci's inbuilt template parser then you should prefer result()..
Posts: 239
Threads: 7
Joined: Oct 2014
Reputation:
16
Yes, it's mostly a matter of personal preference.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Posts: 71
Threads: 4
Joined: Jan 2015
Reputation:
4
thanks guys if It doesn't matter. right now i will still using result() in my generic model.
Posts: 3
Threads: 1
Joined: Mar 2015
Reputation:
0
What about when passed as parameters on a function call? What is the best practice for implementing the function?
function doSomething($data_array)
or
function doSomething($object)?
Posts: 239
Threads: 7
Joined: Oct 2014
Reputation:
16
I'd also say that's a matter of personal preference.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!