Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Is it an good approach to to convert old mysql_ functions to PDO using two connections?
connection 1 - mysqli (procedural: for quick conversion of old mysql_ to mysqli_ )
connection 2 - PDO (for all new functions and gradually converting old mysql_ functions to PDO)
Or is there any better approach.
To me, such a setup makes not too much sense.
There is no need to hurry, and use mysqli for quick conversion.
Just convert to PDO, having one single PDO connection. That's all.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am relatively new to php and I need to connect to a database using php, as i understand there are several methods of connecting to a database, what is the most current method of doing this?
If you are going to use built-in PHP methods, I would advise using PHP PDO. You can find more information on PDO here. You can also use a separate package to manage connections for you such as Doctrine, though this can get a little more complex in the setup. If you are just getting started in PHP, it may be easier to start off with PDO. I hope this helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
A developer I hired decided to use MySQL for a small project. Now he won't respond to me when I tell him I want to switch to SQLite 3.
I was just wondering if there are alternatives for these functions in PHP:
mysqli_set_charset
mysqli_connect
mysqli_select_db
mysqli_query
mysqli_fetch_array
mysqli_fetch_object
mysqli_free_result
mysqli_insert_id
mysqli_affected_rows
mysqli_num_rows
mysqli_fetch_row
mysqli_num_fields
mysqli_field_count
mysqli_fetch_fields
mysqli_real_escape_string
mysqli_error
mysqli_errno
mysqli_get_server_info
mysqli_get_client_info
I scoured the PHP manual.
SQLite3 has it's own API separate from mysql/mysqli.
You can't use mysqli_* functions on an SQLite database.
MySQL and SQLite share the SQL-language so queries written for one will likely work in the other. There are some caveats though.
It's relatively easy to write a database layer that can work with both MySQL and SQLite.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Mysql extension is deprecated as of PHP 5.5.0. For sure that it will be removed in the future. However, I have thousands PHP files written many years ago in procedural instead of object oriented style. I wonder, instead of not updating the server, is there any easiest way to convert all the files with mysql extension to mysqli or pdo?
Did you say thousands of files ?
If they are working fine, I wouldn't modify the code of thousands scripts.
While it is recommended to upgrade, I suggest you to do it only when writing new code.
Every time you refactor some code, there is a risk of breaking, introducing bugs into your application.
you can try with this one: https://github.com/philip/MySQLConverterTool
here you can find some other information and another useful tools: https://wikis.oracle.com/display/mysql/Converting+to+MySQLi
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm currently using mysql_query() to approach DB.
I understand that this method will be removed in the future so I want to learn a new api.
What in your opinion is the best way and why? PDO or mysqli? or there is another one I haven't heard about?
Thank you.
I'm going to offer what I consider to be the best way to handle database stuff: Build your own class. In my case, this class just wraps mysql_* functions, however if I wanted to it would be really easy to change to a different one (such as if mysql_* gets removed). I only have to change a single file, and instantly the entire project is using a new API.
Believe me, do this right at the start and you will save yourself a LOT of work if and when you decide to change things around!
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I was a MySQL PHP coder, but then I realized that is vulnerable to SQL Injections and mysqli_* functions are deprecated, I decided to move on to some other way. I was wondering what is better, MySQLi or PDO?
What is the Most Secure?
What is quick in loading up data?
What is not vulnerable/least vulnerable to SQL Injections?
What is most popular and is preferred by the community?
I need help with these 4 questions and I am here to get them answered. I hope I will find high quality answers.
All three APIs are equally safe, quick and invulnerable.
PDO is preferred by the community because it's being a semi-DAL (Database Access Library) already, while both mysqli and mysql are just raw APIs that shouldn't be used as is but only as a build material for such a library. And because community has no desire/education/habit to create one out of two latter APIs, PDO is left as the only choice.
As an old school programmer you need to know only two things
Every variable should never go into query directly but via placeholder only
unlike mysql, PDO require a connection variable to be always available. Means you need to learn what variable scope is and how to access a global variable.