Database Connection

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Devereaux
Posts: 24
Joined: Wed Nov 28, 2012 3:50 am

Database Connection

Post by Devereaux »

Is anyone taking advantage of PDO yet in their games? I'm trying to learn about proper PDO/DB connections in a pbbg context and I have yet to come across one on here, github, or anywhere else that offers open source. Just curious if pbbg makers are just content on the deprecating mysq_* or what?

After going through all the options for my upcoming game I've decided on using PDO but as a beginner it is super hard to find example code. I'm not interested in frameworks as I thought I would. Just a simple OO game with a PDO connector.
Unnamed Wrestling PBBG in Production
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Database Connection

Post by Jackolantern »

Only the mysql extension is deprecated, not mysqli. If you use prepared statements in mysqli, they work great and are quite secure. That being said, when I do use PHP, I am usually going to use either an Active Records pattern library (usually included with whatever MVC framework I am using), or a full-on ORM solution such as Doctrine. These probably use PDO under the surface, but I don't typically work with it directly.
The indelible lord of tl;dr
User avatar
Hamilton
Posts: 114
Joined: Tue Sep 11, 2012 7:11 am

Re: Database Connection

Post by Hamilton »

This YouTube video may help out (it did for me):
PHP Tutorials: PDO: Connecting to a Database (Part 1/7) - YouTube
http://www.youtube.com/watch?v=XQjKkNiByCk

A seven series video and does go over security. This is what I did like of it, of how to prevent SQL Injections.
Sign off,
Hamilton
User avatar
Elvar
Posts: 86
Joined: Sun Oct 07, 2012 7:04 pm

Re: Database Connection

Post by Elvar »

Jackolantern wrote:Only the mysql extension is deprecated, not mysqli. If you use prepared statements in mysqli, they work great and are quite secure. That being said, when I do use PHP, I am usually going to use either an Active Records pattern library (usually included with whatever MVC framework I am using), or a full-on ORM solution such as Doctrine. These probably use PDO under the surface, but I don't typically work with it directly.
This! I got to admit, i haven't been using PHP without a CMS Framework, or a MVC framework for many year now, so i usually learn whatever they are shipped with. But i vote for Doctrine, specially with Mongodb driver, it is just aawesome, if you are a js nerd like me :D!
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Database Connection

Post by Jackolantern »

I have actually not used PHP much since I first tried out and liked MongoDB, so I didn't know it would map well to it, or really if it was compatible at all. Honestly, document and object databases really remove the need for a lot of the data layer complexity for things such as ORMs, in my experience. I usually just tend to use MongoDB straight. I am assuming there are still good benefits for using something like Doctrine with Mongo? Because it never actually occurred to me to look into it. It also seemed like Mongo stored data out of the box in the form you were using an ORM to finesse relational data into.
The indelible lord of tl;dr
Post Reply

Return to “Beginner Help and Support”