This is a discussion on Arrays as Session Variables? within the PHP Language forums, part of the PHP Programming Forums category; To avoid repeated hits on my database, I'd like to use a single access, from which I can create ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
To avoid repeated hits on my database, I'd like to use a single access,
from which I can create a list of all the records of a particular type which already exist. I'd then have to store the identifiers of all these existing records as the members of an associative array, but I'd have to be able to copy this array's members to a Session Variable. Is this possible? Can I do rec['A']['B'] = true; rec['C']['D'] = true; |
|
|||
|
..oO(Alan M Dunsmuir)
>To avoid repeated hits on my database, I'd like to use a single access, >from which I can create a list of all the records of a particular type >which already exist. > >I'd then have to store the identifiers of all these existing records as >the members of an associative array, but I'd have to be able to copy >this array's members to a Session Variable. > >Is this possible? Yes. Micha |
|
|||
|
Alan M Dunsmuir wrote:
> To avoid repeated hits on my database, I'd like to use a single access, > from which I can create a list of all the records of a particular type > which already exist. > > I'd then have to store the identifiers of all these existing records as > the members of an associative array, but I'd have to be able to copy > this array's members to a Session Variable. > > Is this possible? > > Can I do > > rec['A']['B'] = true; > rec['C']['D'] = true; > . > etc. > . > . > $_SESSION['recs'] = rec; > It's possible, but why would you want to? Databases are made for retrieving data. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Jerry Stuckle wrote:
>> > > It's possible, but why would you want to? Databases are made for > retrieving data. > I believe that that very question is at the centre of the "Web 2" revolution, which has the emphasise switching to asynchronous database access, so as not to slow down too far database Web applications. |
|
|||
|
Alan M Dunsmuir wrote:
> Jerry Stuckle wrote: >>> >> >> It's possible, but why would you want to? Databases are made for >> retrieving data. >> > I believe that that very question is at the centre of the "Web 2" > revolution, which has the emphasise switching to asynchronous database > access, so as not to slow down too far database Web applications. > Not at all. First of all, you are prematurely optimizing. Secondly, your premature optimization may slow down the system. And finally, you're creating more code, which has to be debugged and maintained. But then why not just store everything in a flat file? Then you don't even need a database. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Alan M Dunsmuir <alan@moonrake.demon.co.uk> wrote:
> >To avoid repeated hits on my database, I'd like to use a single access, >from which I can create a list of all the records of a particular type >which already exist. > >I'd then have to store the identifiers of all these existing records as >the members of an associative array, but I'd have to be able to copy >this array's members to a Session Variable. ....which is then stored in a flat file on your server's hard disk (by default), and which gets re-read and re-parsed for every PHP request. Are you sure that's an improvement? -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. |
|
|||
|
..oO(Tim Roberts)
>Alan M Dunsmuir <alan@moonrake.demon.co.uk> wrote: >> >>To avoid repeated hits on my database, I'd like to use a single access, >>from which I can create a list of all the records of a particular type >>which already exist. >> >>I'd then have to store the identifiers of all these existing records as >>the members of an associative array, but I'd have to be able to copy >>this array's members to a Session Variable. > >...which is then stored in a flat file on your server's hard disk (by >default), and which gets re-read and re-parsed for every PHP request. Are >you sure that's an improvement? Impossible to say without more details. In some cases caching the result can be an improvement, for example if the query is complex or the DB is not MySQL where connections are cheap. Micha |
![]() |
| Thread Tools | |
| Display Modes | |
|
|