TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
KO3 MySQLi driver
  • Hi. Coming for kohana 3 a official mysqli driver?

  • Feel free to create one, we would probably include it.

    Personally, I don't see the point. MySQLi doesn't really offer anything more than MySQL, except that you get an OOP API. Am I missing something?

  • @shadowhand None of the DB drivers support multiple resultsets, so if you have a stored procedure that returns a resultset you're out of luck. MySQLi also the ability to send multiple queries in 1 call and supports the advanced functionality of MySQL 4.1+. http://uk.php.net/manual/en/mysqli.overview.php the MySQL extension status is maintenance only.

    I have a fork of Kohana's Database module which I've added experimental support for MySQLi and multiple resultsets (in a branch).
  • @NickUK
    thx
  • The "Internet" says its much better. ;)

    mysqli have (quotes):

    • speed optimized
    • better security
    • more functions
    • multi queries
    • and more...

    more here (german) http://www.phpbuddy.eu/tutorials-und-workshops/13-mysqli-erweiterung-php-5.html?start=1

    Have anybody test this mysqli driver? http://forum.kohanaphp.com/comments.php?DiscussionID=5089&page=1#Item_1

    EDIT: Oh, NickUK was faster.

  • I guess I should have been more clear: What does MySQLi offer that we could implement over MySQL? The answer is: nothing. None of the advanced features of MySQLi could be implemented as defaults because only MySQLi supports them.

    Surely it would be trivial to create a MySQLi driver (basically just replace "mysql_" with "mysqli_", but it doesn't appear to me that it would actually have any benefit.

  • Both PDO and MySQLi support multiple resultsets which I think should be implemented, otherwise the documentation should be clear on what functionality Kohana actually offers to stop confusion?
  • Both PDO and MySQLi support multiple resultsets which I think should be implemented

    But not all databases behind PDO do surely? I guess the difficulty Kohana has is that it wants to maintain a standard functionality that is as database agnostic as possible. This is why there is no transaction support even though (some) MySQL tables and many PDO databases can use them.

    If you need more advanced but database-specific functionality I think it is sensible that you should have to implement this in your own extension. If Kohana Database module had features that only worked in some DB types with certain tables etc, I think it would result in more confusion and would remove a lot of the benefit of the module as an abstraction layer.

    Bottom line: mysqli doesn't add anything that could be implemented without breaking the database agnostic abstraction. For this reason it is sensibly (in my view) left to the developer to implement this as required with the clear understanding that they can't expect the same to work seamlessly across drivers.

    You have a point that the docs should say some of this and hopefully they will soon as a lot more attention is turned to them.

  • @banks and @shadowhand I completely understand where you come from regarding common functionality and leaving specifics to the community, but there has been a number of comments about stored procedures and MySQLi hence the clarification on functionality.
    I forked the module and tacked on MySQLi and a crude attempt at multiple resultsets for myself and anyone else that's interested - I'm not expecting it to be merged in to the main distribution.
  • I implemented a MySQLi driver some time ago. As shadowhand said, I just replaced all instances of "sql" with "sqli". A 10-20 minute job and done.

  • See the bottom of http://www.php.net/manual/en/mysqli.overview.php for differences between mysql, mysqli. Everything that I have read suggests that there is no significant speed difference between to two (the benchmarks I've seen vary, and different types of queries produce different results). I prefer mysqli when I'm using the library directly, but I personally don't care too much what's under the hood of the database library.

  • I might be being completely ignorant, but aren't prepared statements a lot more secure reducing the need for pre-processing?

  • @Dynamism: The database class has prepared statements built in. But prepared statements and stored procedures are not the same thing.

  • It might break the DB agnostic ideals but mysqli does provide the ssl connection support all the other extensions seem to lack. For large systems where PHP and MySQL are not operating on the same server or even the same network, the ability to form an ssl connection to a MySQL database becomes very important, and as such I feel it's worthwhile supporting this driver.
  • Patches welcome. Edit, it looks like this [already exists](http://github.com/Azuka/Kohana-Database-MySQLi).
  • @shadowhand: I'll add an SSL patch to this in the next day or two :)
  • How to add driver mysqli in kohana, because I have problem to query stored procedure.... just mysqli connection can do it, but I don't know how to config and add driver mysqli
  • The advantage of MySQLi is possibility to call stored procedures...

  • PHP 5.5 has deprecated MySQL, and favor MySQLi. Would the Kohana team consider replacing MySQL database adapter with MySQLi adapter?

  • According to this post by @Zeelot3k, Kohana-next will have an official MySQLi driver.

    http://forum.kohanaframework.org/discussion/comment/79417#Comment_79417

  • Very nice. But 3.4.x is far far away. :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion