5. what is the difference between mysql fetch object and mysql fetch array




















Returns an array that corresponds to the fetched row and moves the internal data pointer ahead. The type of array that is to be fetched. Returns an array of strings that corresponds to the fetched row, or false if there are no more rows.

If two or more columns of the result have the same field names, the last column will take precedence. To access the other column s of the same name, you must use the numeric index of the column or make an alias for the column.

For aliased columns, you cannot access the contents with the original column name. Example 1 Query with aliased duplicate field names. Note : Field names returned by this function are case-sensitive. Submit a Pull Request Report a Bug. Warning This extension was deprecated in PHP 5. Parameters result The result resource that is being evaluated. Return Values Returns an array of strings that corresponds to the fetched row, or false if there are no more rows.

Don't fetch BOTH unless you really need them, and most of the time you don't. I have found a way to put all results from the select query in an array in one line. By this you can easily read the entire table to an array and preserve the keys of the table columns. Very handy. Collectives on Stack Overflow. Learn more. Ask Question. Asked 9 years, 11 months ago. Active 3 years ago. Viewed 85k times. Answer 1 Answer 2 Answer 3 Answer 4 I couldn't get the exact idea from the above answers.

Improve this question. Lion Lion Well, the "official documentation" says what? Add a comment. Active Oldest Votes. Improve this answer. Gaurang Gaurang 1, 18 18 silver badges 12 12 bronze badges. The question was asked a long back, a year ago when I didn't differentiate quite properly between them.

An awesome answer. Pacerier, they are one and the same. Personally, I read the documentation and was still a bit confused, mostly because while they could stand independently and make sense, together they are a bit unintuitive. Hence the confusion. Thank you for clarifying that this isnt the case.

See section A. If you name more than one table, you are performing a join. For information on join syntax, see section 6. For each table specified, you may optionally specify an alias. Aware of the fact there's a difference between tables and fields there appears to be confusion here somewhere. You can't use this function to replace some attributes of an existing object keeping the old ones. But imagine each row has fields! Some clarifications about previous notes concerning duplicate field names in a result set.

This can be avoided, as Eskil Kvalnes stated, by aliasing the field names. I created a table, with 5 INT columns, and rows of random ints. Jezze : This wil also work. Also works with static methods.



0コメント

  • 1000 / 1000