Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Storing a PDO instance as a static variable.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="JayC" data-source="post: 346503" data-attributes="member: 36373"><p>That's what I was trying to say was you could do it in a function, and then I found this example <img src="/styles/default/xenforo/smilies/emojione/biggrin.png" class="smilie" loading="lazy" alt=":D" title="Big Grin :D" data-shortname=":D" /> Let me play around with a few things and see if I can get it.</p><p>[DOUBLEPOST=1439083029,1439081999][/DOUBLEPOST]Alright, after looking more into PDO and what it does as I don't use PDO, and playing around with connecting to a database I have found out a few things (Also using prior knowledge as I mainly code in mysql/C#/Java) </p><p>1. You shouldn't use static variables, ever. Static variables are a bad idea, because now everything you make is going to have to be static in order to connect, and then it will turn out to be more lengthy then what you are trying to do!</p><p>2. You can't make PDO instance into a static variable, and if you make the static method say bye bye to encapsulation <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p><p>Sorry I couldn't help more, but I wouldn't use static if I was you.</p></blockquote><p></p>
[QUOTE="JayC, post: 346503, member: 36373"] That's what I was trying to say was you could do it in a function, and then I found this example :D Let me play around with a few things and see if I can get it. [DOUBLEPOST=1439083029,1439081999][/DOUBLEPOST]Alright, after looking more into PDO and what it does as I don't use PDO, and playing around with connecting to a database I have found out a few things (Also using prior knowledge as I mainly code in mysql/C#/Java) 1. You shouldn't use static variables, ever. Static variables are a bad idea, because now everything you make is going to have to be static in order to connect, and then it will turn out to be more lengthy then what you are trying to do! 2. You can't make PDO instance into a static variable, and if you make the static method say bye bye to encapsulation :) Sorry I couldn't help more, but I wouldn't use static if I was you. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Storing a PDO instance as a static variable.
Top