Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6530645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:46:51+00:00 2026-05-25T09:46:51+00:00

Well, I’m relatively new to php but have worked on web apps previously. I’m

  • 0

Well, I’m relatively new to php but have worked on web apps previously.
I’m currently writing code in php and running Apache httpd. The DB I’m using is PostgreSql.

This web app will connect to DB very frequently. For that reason I’m looking for something that enables me not to initiate connection every time a user accessed a page.

Is it possible in php to set a variable that is same for all users.

For eg. I want to save a DB connection object in a variable and use it whenever I want.

That variable will go out of scope when Apache Server stops.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:46:51+00:00Added an answer on May 25, 2026 at 9:46 am

    Smarmy answer first. Yes you can. It’s called the database 😉

    Seriously though, Apache + PHP (without anything else) is not the best option if you’re trying to persist values across requests. Normally, if that type of functionality is needed, it is done through either a hard file or a database connection which is refreshed every time a request is triggered. Obviously neither of those are sufficient to persist an entirely separate connection.

    The general rule is one request one connection. There are ways to persist connections so that this number is lowered but pg_connect which was supposed to be a canonical way to approach this problem, seems to be incredibly broken. You may wish to look into pgbouncer or pgpool instead. I don’t know how the PDO driver handles ATTR_PERSISTENT for Postgre.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I have been through many sites teaching on how to solve it, but
Well, I have this bit of code that is slowing down the program hugely
Well friends, I have got this query which works but is very long for
Well, after a long time writing .net programs in C# I started to feel
Well, this is my first post here and really enjoying the site. I have
Well... simple question, right? But with no so simple answers. In firefox i use
Well, it seems simple enough, but I can't find a way to add a
well i have this messages table with sample values like these: msg_id recipient_id read
Well, I have this jQuery image slideshow that uses the attribute control inside an
Well I have a Pop up in the WebBroswer control of the .NET Framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.