Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #13777
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: mysqli fetch_assoc() straight to array |
| Date | 2014-06-01 10:35 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lmevla$9bn$1@dont-email.me> (permalink) |
| References | (2 earlier) <1jha1xk2xj4hw.1012a4ildu9nd.dlg@40tude.net> <5388f400$0$6665$9b4e6d93@newsspool3.arcor-online.net> <lmb95p$d3e$2@dont-email.me> <lmd3c0$rv9$9@dont-email.me> <lmd9ag$277$1@dont-email.me> |
On Sat, 31 May 2014 15:08:05 -0400, Jerry Stuckle wrote: > On 5/31/2014 1:26 PM, Denis McMahon wrote: >> On Fri, 30 May 2014 20:53:17 -0400, Jerry Stuckle wrote: >> >>> On 5/30/2014 5:11 PM, Christoph Michael Becker wrote: >>>> richard wrote: >> >>>>> I just figured there had to be some way of being able to assign the >>>>> columns within the function, but apparently not. >> >>>> Maybe you're looking for mysqli_stmt_bind_result()[1]? >> >>> No, he's not... >> >> I think I know what he's looking for, but his OP was so badly worded >> regarding what he's trying to do that it's really hard to tell. >> >> > You're doing better than I am then, Denis. I'm definitely unsure of > what he really wants. In his original post, he's using fetch_assoc and talking about getting all the columns, and also talking about 2d arrays. Of course fetch_assoc does get all the columns, as a 1d array. I think he's confusing columns and rows, and what he means is that he wants to fetch all the rows as a 2d array. As we almost all (except richard and maybe a couple of others) know, php doesn't really have multi-dimensional arrays, but it has a simulation of them by nesting 1d arrays n-levels deep[1]. I think he's thrown us all of scent of what he actually wants by the typical richardism of getting the words "rows" and "columns" mixed up. fetch_assoc fetches one row of columns as a 1d array What he wants is (what he calls) a 2d array (and is actually nested 1d arrays to 2 levels) containing all the rows of the result set. So his example code to do this with fetch_assoc should have looked something like: while ( $row = mysqli_fetch_assoc( $result ) !== FALSE ) $rows[] = $row; Whereas the single call method he's actually looking for is: $rows = mysqli_fetch_all( $result, MYSQLI_ASSOC ); This is probably where I need to say "richard, read the fucking manual for mysqli_fetch_all, especially the note about memory useage!" and richard ignores me, only to come back later moaning that mysqli_fetch_assoc doesn't work, when it does, but his process doesn't have enough memory allocated by the hosting service for his screwed up database design to use it. Of course, to us[2] this is just another good reason to normalise a database, but then we all know that richard doesn't do normal. [1] For the ignorant, a true multi-d array is keyed arr[a,b,c,d .... ], not arr[a][b][c][d]....[] [2] People who understand databases. -- Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: mysqli fetch_assoc() straight to array Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-30 16:23 -0400
Re: mysqli fetch_assoc() straight to array Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-30 16:25 -0400
Re: mysqli fetch_assoc() straight to array richard <noreply@example.com> - 2014-05-30 17:36 -0400
Re: mysqli fetch_assoc() straight to array Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-31 10:32 -0400
Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-31 17:21 +0000
Re: mysqli fetch_assoc() straight to array richard <noreply@example.com> - 2014-05-30 16:54 -0400
Re: mysqli fetch_assoc() straight to array Jürgen Exner <jurgenex@hotmail.com> - 2014-05-30 14:08 -0700
Re: mysqli fetch_assoc() straight to array Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-30 23:11 +0200
Re: mysqli fetch_assoc() straight to array Jerry Stuckle <jstucklex@attglobal.net> - 2014-05-30 20:53 -0400
Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-31 17:26 +0000
Re: mysqli fetch_assoc() straight to array Jerry Stuckle <jstucklex@attglobal.net> - 2014-05-31 15:08 -0400
Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-01 10:35 +0000
Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-30 23:27 +0000
Re: mysqli fetch_assoc() straight to array Jerry Stuckle <jstucklex@attglobal.net> - 2014-05-30 20:52 -0400
csiph-web