MySQLi — OO or Procedural?

2019-05-21 02:47发布

问题:

I know OO is the "way to go" but I'm thinking procedural might be easier to use in the wrapper I'm making.

Any difference in performance between MySQLi Object Oriented vs Procedural?

回答1:

This is premature optimization. There's no difference, unless you're really crunching for picoseconds and femtoseconds.

Edit: which you will NOT be crunching.



回答2:

Not really. There might be a very slight difference, but it's largely negligible. The object-oriented one is, in my opinion, much easier to use, though, even if you are making a wrapper over it anyway.



回答3:

The difference is not in regards to MySql or MySqlI but main the fact of using objects over procedural,

Using objects will create reusable code, this being said your applications will be smaller and they tend to have less memory/resource usage.

My Advice is get started with PDO Its an Abstraction layer writter for PHP and is available for several different database servers such as mysql(i)

Read more about the usage here: http://php.net/manual/en/book.pdo.php



回答4:

I would suggest checking out the Doctrine Project. They have a great ORM, but if you just want to use the DB abstraction, they've actually separated the DAL out into another project, for people who don't want to use the ORM.



标签: php mysqli