• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Database query into session array??

LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

Hello, all.

I've got a hard-coded nav & subnav that I'd like to convert to dynamic. But I don't want to use a query for every page load; I'd like to pull the data from a session variable that queries the database once. Is it possible to insert an array into a session variable? If not, is there another way to do this so that the database isn't queried for every page load?

Thanks,

^_^
TOPICS
Advanced techniques

Views

553

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

yes...I change a query to a struct and then store it in a session var
when the user logs in. Then I refer to the session.structname.qcolumn to
get the value.
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

> yes...I change a query to a struct and then store it in a session var

Why would you not just stick the query itself into a session var? What's
the perceived gain of changing it to a struct first?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

no "perceived gain", preference and ease of use...the OP asked if it was
possible...come on Adam...there's five ways to do anything in CF... ;-)
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

I would use the query to generate all the nav html and store THAT in the session var.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

Hmmmm.. interesting idea.. sounds like a tanker-full of coding on the SQL-side, but it would certainly be interesting to do.

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

It's not that hard if you use CSS driven sites.

But, no, CF code generates the html from the query and then stores that nav html into the session.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

Well, I'm not using table-less CSS layout. I'm just using CSS to declare the font. Still using a table for layout control, so that would be a lot of coding. Still an interesting idea, though.

But I am most likely going to try to insert the query directly into a session variable, first.

If that doesn't work, I'll try the first suggestion of converting to a struct.

If that doesn't work, I'll probably just stand on the rear deck and scream funny noises as loudly as I can until the men in white coats come to get me. :)

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

LATEST
> If that doesn't work, I'll probably just stand on the rear deck and scream
> funny noises as loudly as I can until the men in white coats come to get me. :)

This is a much better approach than that whole "working out what to put in
the session scope, if anything" thing we were discussing.

Glad we got there eventually.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

> no "perceived gain", preference and ease of use...the OP asked if it was
> possible...

... to use an *array*, I believe ;-)

> come on Adam...there's five ways to do anything in CF... ;-)

And some approaches are better than others. Like not unnecessarily
buggering about with data that is probably already in the most suitable
format to start with.

But I thought you might be onto something, so figured it worth asking
about.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2006 Dec 07, 2006

Copy link to clipboard

Copied

and my query only returns 1 record anyway...I'd probably store the whole
query if it had more records, or cache the query in CF or on the Db
server...many possibilities depending on exact need.
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation