Welcome Guest, Not a member yet? Register   Sign In
mysql_fetch_row() in CodeIgniter
#11

[eluser]punchi[/eluser]
[quote author="jedd" date="1260761746"]
Hang on - you're saying that you want to ignore the ordering or your SQL function? Why not just

get the ordering done properly in the first place?
[/quote]

No, no, I wrote it as example. The real thing is: Im doing some similar pages for querys, so instead of rewrite the code in the view (write the same fields in both model and view), just write the SQL and show it in the view with the same order (and well.. for something exist the function in PHP too :-P ).

Quote:I'm assuming that $query in your controller is taking the $retdata from the model? You didn't

show the code - and I don't like assumptions.

In any case, print_r() of $query here would be far more instructive, I suspect.

What does sizeof() report?

Yes, the control just call the model and pass the return [...] of the function to the view in a variable with "query" name

And yes, the print_r($query) must be the code.

Code:
Array (
    [0] => Array (
        [ID_PLAN] => 1
        [PL_NAME] => Plan Básico
        )
    [1] => Array (
        [ID_PLAN] => 5
        [PL_NAME] => Plan Básico
        )
)

As you may see, to get the first element is row[0][ID_PLAN], no row[0][0] as needed (and done with the proper code)

Quote:[quote author="punchi" date="1260759436"]
The page speed up a 350% (from 0.0035 to 0.0010).

How big is your sampling set, and under what conditions? This differential seems pretty trivial at a glance.
[/quote]

Both information is loaded in the same page, with one function I call the call_function method and with another function I call the mysql_fetch_row method. Same page, same conditions, using the benchmaker utility. However isnt too strange that the 2nd one is more quicly, its a native instruction.

And well, yeah, looks trivial with 50 rows with 2 elements. But with 500 rows with 10 elements, and many users doing the query, it cares.

Quote:What I don't know, if working with CodeIgnite and PHP native functions, have some incompatibilities or is inappropriate...

Quote:What kind of incompatibilities are you thinking of here? I think they'd probably have noticed if such things existed by now. Wink

I thought in closing connections for example or... i don't know maybe CI works in a different way with DB, and accessing directly to MySQL can have a problem... just asking and being careful Smile




Theme © iAndrew 2016 - Forum software by © MyBB