Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > Question about sqli class
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 3rd November 18:28
iorm
External User
 
Posts: 1
Default Question about sqli class



I donīt know if this is the correct place to ask this questions but I haver some doubts about using mysqli class in php. I am designing a web place using wamp2 (php5, mysql 5.0.x ....). My databases have been done using phpmyadmin so they are "normal" mysql, I mean that I have done nothing with SQLITE. On the other hand, I am accessing to my databases and tables using mysqli class and methods for example:
$conn = new mysqli ( ..........) (this is what I am using)
I am using that because I read in the internet that mysqli methods where more efficient but I donīt know if itīs correct to use that methods with my mysql database (it runs perfect).

so... is it correct? supposing that itīs correct to use it......is it faster and better to use mysqli methods than using the functions that were used before these new classes appeared?

thanks...

my email is:
iorm@euskalnet.net
  Reply With Quote


 


2 3rd November 18:29
quickshiftin
External User
 
Posts: 1
Default Question about sqli class



i believe the main reason for mysqli being 'better' than mysql is the object
oriented approach to the api design.
there may be other optimizations under the hood, but i am not aware of any
off the top of my head (list: feel free to correct me).

as per your overall system design, deciding to go w/ mysqli comes down to a
few things
- do you want to write all the sql by hand
- do you plan on using a different database w/ the same system

there are more questions of course but anyway; what im getting at is you
might want to take a look at something like propel
http://propel.phpdb.org/trac/

there are similar systems out there, but to summarize their features they
essentially use a code generation paradigm to write
all the database i/o in your system on your behalf; then you can just start
using it. it is customizable as well.
you will find pros / cons to such a system and a learning curve. but mainly
i just want to acquaint you with such systems.

anyway if youre not going to use something like that id say shoot for mysqli
over mysql.

-nathan
  Reply With Quote


 


3 4th November 09:54
larry
External User
 
Posts: 1
Default Question about sqli class


Both ext/mysql and ext/mysqli work exclusively with MySQL databases. They could not talk to SQLite, which is a different database engine entirely.

If you have the choice and are using MySQL 5 and PHP 5, ext/mysqli is generally faster than ext/mysql. More importantly, it supports native prepared statements which is easier to use and more secure than trying to do your own escaping.

Better still would be to use PDO, which provides the advantages of ext/mysqli and supports a half dozen databases using the same (or nearly the same) OO API.

Even better than that is to write your own thin wrapper API and then use mysqli or PDO under the hood. Then if necessary you can switch from one to another with only minimal impact on your application code.

Whether the API is OO or function-oriented doesn't make a huge difference. Prepared statements do.

--Larry Garfield
  Reply With Quote
4 4th November 09:56
ceo
External User
 
Posts: 1
Default Question about sqli class


You can use either of the clients to access the DB safely.
[At least in theory. I suppose there could exist some unknown bug
that makes a serious difference...]


It might or might not be faster, depending on a lot of factors, I
suspect...

It also might be a lot less stable, since it's a lot less pounded upon
by millions of users.

The speed difference will probably be completely irrelevant to you in
your real-life usage, if you're having to ask here...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
  Reply With Quote
Reply


Thread Tools
Display Modes




666