MySQLi — OO or Procedural?

2019-05-21 02:15发布

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?

标签: php mysqli
4条回答
做自己的国王
2楼-- · 2019-05-21 02:44

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

Edit: which you will NOT be crunching.

查看更多
Anthone
3楼-- · 2019-05-21 02:58

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.

查看更多
混吃等死
4楼-- · 2019-05-21 03:00

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.

查看更多
劳资没心,怎么记你
5楼-- · 2019-05-21 03:08

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

查看更多
登录 后发表回答