Skip to content
Magenaut

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

singleton

php singleton database connection, is this code bad practice?

November 20, 2022 by Magenaut

I’m trying to create a simple to use singleton class to connect to mysql database and do queries, the code works fine and i haven’t had any problems with it, but since I’m new to OOP I’m wondering whether this is bad practice or not.

Categories MySQL, Q&A Tags class, mysql, oop, php, singleton Leave a comment

PHP singleton database connection pattern

November 16, 2022 by Magenaut

I’ve been working on a small project using PHP and MySQL. I’ve read a lot around about best practices on managing a connection and so on.

Categories MySQL, Q&A Tags mysql, mysqli, php, singleton Leave a comment

React native- Best way to create singleton pattern

November 1, 2022 by Magenaut

I am new in react-native coding but have experienced on objective-c and swift coding and want use singleton pattern in react-native.
I have tried to find out the solution from other StackOverflow answer but most of them are creating only singleton functions as below code:

Categories Q&A, ReactJS Tags react-native, reactjs, singleton Leave a comment

Export of a class instance in Javascript

October 27, 2022 by Magenaut

I was looking at this code where a class instance is exported in a little bit weird way.

Categories Q&A, ReactJS Tags export, javascript, reactjs, singleton Leave a comment

Creating the Singleton design pattern in PHP5

October 21, 2022 by Magenaut

How would one create a Singleton class using PHP5 classes?

Categories PHP, Q&A Tags design-patterns, oop, php, singleton Leave a comment

Is there a use-case for singletons with database access in PHP?

October 21, 2022 by Magenaut

I access my MySQL database via PDO. I’m setting up access to the database, and my first attempt was to use the following:

Categories PHP, Q&A Tags design-patterns, oop, php, singleton Leave a comment

Global or Singleton for database connection?

October 20, 2022 by Magenaut

What is the benefit of using singleton instead of global for database connections in PHP? I feel using singleton instead of global makes the code unnecessarily complex.

Categories PHP, Q&A Tags design-patterns, php, singleton Leave a comment

Best practice on PHP singleton classes

October 20, 2022 by Magenaut

Possible Duplicate:
Who needs singletons?

Categories PHP, Q&A Tags class, design-patterns, oop, php, singleton Leave a comment

How is testing the registry pattern or singleton hard in PHP?

October 17, 2022 by Magenaut

Why is testing singletons or registry pattern hard in a language like PHP which is request driven?

Categories PHP, Q&A Tags php, singleton, static, testing Leave a comment

get_instance() in Codeigniter: Why assign it to a variable?

October 13, 2022 by Magenaut

In Codeigniter, get_instance() is a globally available function that returns the Controller super-object which contains all the currently loaded classes (it returns the Controller class instance). I’ll include the current source code:

Categories PHP, Q&A Tags codeigniter, php, reference, singleton Leave a comment
Older posts
Page1 Page2 Page3 Next →

Recent Comments

  • silverplugins217 on How to add placeholder for contact form7 for dropdown?
  • Shreyas Ikhar on How to add a custom CSS class to core blocks in Gutenberg editor?
  • Magenaut on How to call function on timer ASP.NET MVC
  • Ebaad Uddin on How to call function on timer ASP.NET MVC
  • michealSmith07 on Is there a way to dynamically refresh the less command?

Tags

.net adobe-illustrator adobe-photoshop ajax arrays asp.net asp.net-core asp.net-mvc bash c# css database django eloquent express html java javascript jquery json laravel laravel-4 laravel-5 laravel-8 linux list mongodb mongoose mysql node.js npm pandas php python python-3.x react-hooks react-native react-router reactjs redux regex sql string typescript wordpress
© 2023 Magenaut • Built with GeneratePress