Is it OK to use SQL Server or Mysql with PHP?

Asked

Viewed 500 times

4

I’m putting together a medium project and I’m going to model the bank, then create the tables, the views, as procedures beyond the bank itself of course. I would create everything with Mysql, but by already messing with SQL Server, I thought I could use the same instead of Mysql.

Everything I can do with PHP + Mysql I can also with PHP + SQL Server?

With the pros and cons that each database language would have when using with PHP, it is worth using SQL Server which is a database with more features, or using Mysql itself, which is more used with PHP?

1 answer

6


The basic yes, it’s all the same, but came out of the "rice and beans" already changes everything. Changes the syntax of the SQL commands (not deeply, but incompatible in various details), and mainly changes what can be configured in the database and the various ways of optimization.

You can make the same model fit "well", but this is obtained with the "lowest common denominator" technique that will always make the application stay a little the desired. In some cases it may not be a big problem, in others it may be a huge one. It has several features that are only found in one of them, but it also has several that are identical in both.

So I think it’s silly the person who loves PDO, Entity Framework and other things like that, for the reason that they abstract the database and allow to change the vendor later. If it were that simple I would love to, but in practice if I do, the application will suffer. Luckily most end up "abstracting" the database but optimizes for one and never changes (which is the opposite of what she thought she was going to do, and shows that she has no idea what she’s doing). This is one of the biggest lies told in computing.

  • Do you think it’s worth using mysql better? Because if I were to use it with Sql Server, I would have to use it with PDO. But if I choose mysql, I will not use PDO, but mysqli. I believe that this is the only doubt that persists before my choice.

  • There I can not say, each case is a case, depends on the project, the person who will work and other specific factors. I may be wrong but I don’t know if you need PDO to use SQL Server. I always avoid PDO.

  • But, the PDO was not implemented to literally turn on the "I don’t care what DB it is"? So much so that still comes Doctrine, among other Ibraries and Patterns??

  • 2

    Has a specific driver for SQL Server sqlsrv replacing the old mssql.

  • yes no need. There are other modes I’ve used. However if it were with sql server, I think I would use PDO. But pq you avoid bigown PDO?

  • But rray. If I’m not mistaken, this driver contains far fewer functions than mysql native.

  • @Williamaparecidobrandino this is the promise, and the unsuspecting fall into it. It works? Of course. It’s good, no. It’s good for a lot of people? Yes.

  • 2

    @Dichrist PDO is an extra layer whose only real advantage is to do something that is impossible to do well. I think there is a question here. I need to see one that has good answers. And does PDO do how to access SQL Server? Does it have a wonderful driver of its own? I don’t think so. But it is getting to the point of what I put in the answer. There are numerous differences. The PDO does not miracle, it does not use the maximum common denominator, it uses the minimum.

  • @Dichrist would be the lack of a function for example to pick up the inserted id(mysqli_insert_id())? have some example?

  • 1

    mysqli_connect_errno(), mysqli_refresh(), mysqli_fetch_assoc() are some of them rray. I do not remember all and if not in mistake, there are no exact correspondents for these functions.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.