PHP MySQL to SQLite 3, do equivalent functions exist? [closed] - php

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.

Related

What is the easiest way to update Mysql to either mysqli or pdo [closed]

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

MySQLi and PDO Connection in PHP [closed]

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.

converting a script from mysql_ to mysqli_ or PDO [closed]

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.

Convert mysqlcodes to mysqli [closed]

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 9 years ago.
Improve this question
Is it usefull to convert all my PHP codes from mysql to mysqli?
I mean will mysql be deleted? And is there a tool that converts my codes to mysqli? Or do I just have to change all i.e. mysql_query to mysqli_query?
Is it useful?
Yes, read Why shouldn't I use mysql_* functions in PHP? So if you plan on running your code in years to come, you should consider it.
Is there a tool?
This tool if often mentioned but I have never tried it and I think you would learn more by doing it manually. It also seems more complicated than doing it by hand if you're a beginner.
Changing all your mysql_query() function calls to mysqli_query() is not enough. The mysqli_query function requires that you pass a link identifier as the first argument wheareas with mysql_query "If the link identifier is not specified, the last link opened by mysql_connect() is assumed."
And of course it's not just the mysql_query calls you would have to change, but all mysql_* calls.

PHP PDO vs normal mysqli speed performance benchmark [closed]

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 9 years ago.
Improve this question
i m working on a project about social networking website where speed optimization is very critical.
is PDO is FASTER ?
i am thinking to switch to PDO is it recommended for use PDO for such a site ?
I doubt using PDO or MySQLi will be bottleneck, though, if you ask for bechmarks, here they are (nothing serious, just couple of tests).
In general, using one or another is a matter of taste, and bottlenecks usually are somewhere else (e.g., queries, indexes, PHP code etc).
One thing you might consider is using some DB wrapper, i.e., class that uses either PDO or MySQLi, whichever you prefer. In your code, use this wrapper instead of using PDO or MySQLi directly. If you do this, you'll be able to switch between PDO, MySQLi or any other library by changing single class instead of changing all the code.
I did a mini benchmark on this a while back. Conclusion. PDO and MySQLi are very similar but the features in PDO are worth using.
http://cznp.com/blog/2/apples-and-oranges-mysqli-and-pdo

Categories