Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Registration.php : PDO support #154

Merged
merged 1 commit into from
Aug 20, 2013
Merged

Conversation

devplanete
Copy link
Contributor

Replace mysqli functions by PHP PDO functions in all database calls.

Replace all direct calls to "new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME)" by the function "private function databaseConnection()"
This function check if database connection already opened, create connection if needed and return true or false (if false, error message is added to error string of the class)

Replace mysqli functions by PHP PDO functions in all database calls.

Replace all direct calls to "new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME)" by the function "private function databaseConnection()"
This function check if database connection already opened, create connection if needed and return true or false (if false, error message is added to error string of the class)
@panique
Copy link
Owner

panique commented Aug 17, 2013

This is a good feature, thanks for that, but we already had a discussion about that several months ago here: Do the users, that use 2-advanced version, really know what PDO is and how to use it ? If they wand to build an application out of it, is it even useful to bring PDO into the game ?

@GrahamCampbell
Copy link
Contributor

I agree with @panique. This script is meant to be accessible to everyone (i hope i'm on the right lines here), and although many people understand pdo, some do not.

@devplanete
Copy link
Contributor Author

PDO is standard since PHP version 5.1 (far away) and it's a key feature for safety on SQL injection.
As you can see in my code, syntax is very similar to MySQLi and people can also learn by reading the code.

MySQLi is the old way to do and PDO is the futur of PHP, so people have to learn...

You can keep MySQLi for 1-minimal if you want but 2-advanced is already address to a public knowing PHP. Don't migrate to PDO now will be more difficult when php-login will be bigger.

@panique
Copy link
Owner

panique commented Aug 18, 2013

@devplanete That might be totally true, but the reality is that most people who use this script dont even know what PDO is. This leads to the question: Do we want to "teach" the users to use PDO, or simply provide a script that fits their current coding behaviour ? And do users reject scripts if it uses an "unknown" technology ?

Does anybody know some statistics about this ?

By the way: The 4-full-mvc-framework uses PDO.

@GrahamCampbell
Copy link
Contributor

Personally, I think it would be stupid to reject a technology just because you think it's hard or you can't be arsed to learn it. Just saying...

@devplanete
Copy link
Contributor Author

@panique Please let me know your final decision about PDO inside 2-advanced.

I think that I will migrate Login.php to PDO in the coming days but if you are not interested in... I will have to maintain my own version and it will not be an easy task...

@panique
Copy link
Owner

panique commented Aug 19, 2013

I would like to ask into the room: What are the DISadvantages when implementing PDO into 2-advanced ?

In my opinion the important points are:

  1. A special percentage of users who has never heard PDO before will not even look on the project.
  2. Nearly all people will have to have a deep look into PDO tutorials (PDO is a quite professional thing I think, and professional are probably not using this script)
  3. The script is open-source and non-commercial, so we don't really care when less people are downloading / using the script
  4. 0-one-file uses PDO too.

Ahhh let's use PDO ;)

It's not a popular choice, but it's the right choice ;)

But: let's write a guideline on using PDO, as the people will definitly need this!

@panique
Copy link
Owner

panique commented Aug 19, 2013

@devplanete Wonderful, let's go PDO! Thanks for the commit, I'll merge it when all database requests are PDO-style (otherwise it wouldn't make sense to merge).

@devplanete
Copy link
Contributor Author

ok thanks for your support, I'm convinced that it's the best choice

@Dominic28
Copy link
Contributor

I think that's the right choice, too.
I never used PDO until I looked at the mvc version of the script. People who really want to use this script because of its advantages, will learn how to use PDO.

So it's okay to do that ;)

@GrahamCampbell
Copy link
Contributor

@Dominic28. That' basically a polite version of what I said. Lol.
Also, @panique, pdo is pretty popular, just not so much with beginners. Many other larger php database libraries leverage pdo under the hood, like doctrine dbal.

@ghost
Copy link

ghost commented Aug 20, 2013

I vote for PDO. PDO is the modern way of handling databases in PHP =)

panique added a commit that referenced this pull request Aug 20, 2013
Update Registration.php : PDO support
@panique panique merged commit e8b7c99 into panique:develop Aug 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants