ProductCart E-Commerce Solutions Homepage
Forum Home Forum Home > ProductCart > Customizing ProductCart
  New Posts New Posts RSS Feed - Why isn't opendb.asp included in inc_theme_common?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Why isn't opendb.asp included in inc_theme_common?

 Post Reply Post Reply
Author
Message
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Topic: Why isn't opendb.asp included in inc_theme_common?
    Posted: 11-June-2017 at 7:44pm
I've been trying to use the JSON parser and pcf_OpenUTF8 within my theme, but I couldn't get it to work. Eventually I found out that the issue was related to ErrorHandler.asp not being included.

I ended up having to include opendb.asp to the list of includes in include_theme_common.asp, and include ErrorHandler.asp in that same list of includes.

Now it appears to be working, and pcf_OpenUTF8 is opening the file and I am able to parse it with JSON.

Is there any reason opendb.asp wasn't included in include_theme_common.asp and that instead a different copy of the openDB function was hardcoded at the bottom of inc_theme_common.asp?

Ideally I'd like to leave these changes as is, with opendb.asp and errorhandler.asp being included with inc_theme_common.asp, but if this is some kind of security risk or other issue then I suppose I'll need to find a workaround.
Back to Top
Matt View Drop Down
Moderator Group
Moderator Group


Joined: 20-July-2006
Location: United States
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote Matt Quote  Post ReplyReply Direct Link To This Post Posted: 11-June-2017 at 9:54pm
Including "opendb.asp" worked because it automatically opens a database connection, but that's the reason it's not included.  You want to be able to control when a database connection is open, and in most cases you don't want to open one within the header or footer.  Think about the data you need and try to save it as a static asset, or at the least cache it.  Try not to include anything dynamic in your head and footer that is going to use resources unnecessarily. However, if you have a good reason to connect to the database, contact a remote service, and parse JSON on each page load.  You should remove opendb.asp and just call the open function.

e.g. 

' Open db
call openDB()

' do something...

' Close db
call closeDB()

If you are including "opendb.asp" and not closing the connection, then you have a leak.
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 13-June-2017 at 7:26am
Thanks for the explanation Matt. I'm trying to use webpack to setup an asset pipeline, and typically I'd read the assets from an assets.json file. I took your advice and reverted the changes to inc_theme_common.asp. I'll have to figure out some other way to parse the assets file.

I definitely don't want to continuously connect to the DB and stuff. It already seems like this is happening too much between the regular execution, and then theme.asp, header.asp, and footer.asp (which all seem to include inc_theme_common.asp since they all run in their own context due to being included via server.execute.

I'll let you know what I end up going with.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.