HHVM – Implementing MySQLi

Visit the post for more.

Emil Hesslow
6 min readintermediate
--
View Original

Overview

The article discusses the implementation of the MySQLi extension in HHVM, detailing the preparation, implementation, testing, and challenges faced during the process. It highlights the importance of MySQLi for compatibility goals and provides insights into the testing methodologies used to ensure correctness.

What You'll Learn

1

How to implement MySQLi in HHVM using HNI

2

Why testing with the Zend test suite is crucial for MySQLi implementation

3

How to handle variable number of arguments in PHP extensions

Prerequisites & Requirements

  • Understanding of PHP and its extensions
  • Familiarity with GitHub for accessing HHVM code and documentation(optional)

Key Questions Answered

What challenges were faced during the MySQLi implementation in HHVM?
The implementation faced challenges such as supporting variable number of arguments and handling ZendParamMode. These issues required enhancements to the HHVM Native Interface to accommodate the necessary functionality.
How does HHVM's MySQLi implementation compare to Zend's?
HHVM currently passes 182 of the Zend MySQLi tests but fails 114, many of which are due to technicalities like output differences. However, it achieves 100% compatibility with real-world frameworks like Doctrine and CodeIgniter.
What is the current status of the MySQLi implementation in HHVM?
As of now, the MySQLi implementation passes 182 Zend tests and fails 114, with many failures being technicalities. The implementation is planned for release in HHVM 2.5.0.
What are the missing pieces in the MySQLi implementation?
Key missing pieces include support for reading default values from php.ini, differences in error messages, and the lack of support for functions requiring the MySQL Native Driver.

Key Statistics & Figures

Zend MySQLi tests passed
182
Out of a total of 296 tests, indicating a strong but incomplete implementation.
Zend MySQLi tests failed
114
Many failures are due to technicalities rather than functional issues.
Real-world compatibility tests passed
100%
Both Doctrine DBAL and CodeIgniter unit tests pass when running on MySQL.

Technologies & Tools

Backend
Hhvm
Used as the runtime environment for implementing MySQLi.
Database
Mysqli
The extension being implemented to enhance database interaction.
Framework
Zend
Reference framework for compatibility testing.

Key Actionable Insights

1
Implementing MySQLi in HHVM can significantly enhance compatibility with existing PHP applications.
This is particularly important for developers looking to migrate applications to HHVM while maintaining functionality.
2
Utilizing the Zend test suite for testing your implementation can help identify compatibility issues early.
This approach ensures that your implementation aligns closely with established PHP standards, reducing the risk of runtime errors.
3
Leveraging the HHVM Native Interface (HNI) can simplify the process of writing PHP extensions.
By using HNI, developers can avoid the complexities of C++ and focus on PHP, making extension development more accessible.

Common Pitfalls

1
Failing to account for variable number of arguments in functions can lead to incomplete implementations.
This is particularly relevant in PHP extensions where such features are essential for compatibility with existing PHP functions.
2
Neglecting to run tests in parallel can slow down development significantly.
Updating test scripts to avoid conflicts when running tests in parallel is crucial for maintaining development speed.

Related Concepts

Php Extensions
Hhvm Native Interface
Mysqli Functionality
Zend Compatibility