Download the PHP package stefangabos/zebra_database without Composer
On this page you can find all versions of the php package stefangabos/zebra_database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stefangabos/zebra_database
More information about stefangabos/zebra_database
Files in stefangabos/zebra_database
Package zebra_database
Short Description An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.
License LGPL-3.0-or-later
Homepage https://github.com/stefangabos/Zebra_Database
Informations about the package zebra_database
Zebra Database 
A PHP MySQLi database wrapper that's lightweight, secure and feature-rich, providing methods for interacting with MySQL databases that are more secure, powerful and intuitive than PHP's default ones.
Zebra_Database supports transactions and provides ways for caching query results either by saving cached data to the disk, in the session, by using memcache or redis.
The library provides a comprehensive debugging interface with detailed information about the executed queries: execution time, returned/affected rows, excerpts of the found rows, error messages, backtrace information, etc. It can also automatically EXPLAIN SELECT queries (so you don't miss those keys again!).
Provides debugging information when called from CLI (command-line interface) and supports logging queries done through AJAX requests.
It encourages developers to write maintainable code and provides a better default security layer through parameterized queries, where values are given separately from the SQL and are automatically escaped and quoted for you.
The code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL.
:microscope: See the debugging console in action
Key Features of this PHP MySQLi Wrapper
-
it uses the mysqli extension extension for communicating with the database instead of the old mysql extension, which is officially deprecated as of PHP v5.5.0 and will be removed in the future; this is not a wrapper for the PDO extension which is already a wrapper in itself!
-
can provide debugging information even when called from CLI (command-line interface)
-
logs all queries, including those run through AJAX
-
offers lots of powerful methods for easier interaction with MySQL
-
supports unbuffered queries
-
provides a better security layer through parameterized queries, where values are given separately from the SQL and are automatically escaped and quoted
-
provides a very detailed debugging interface with lots of useful information about executed queries; it also automatically EXPLAINs each SELECT query
-
supports caching of query results to the disk, in the session, or to a memcache or to a redis server
- code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL

:notebook_with_decorative_cover: Documentation
Check out the comprehensive PHP MySQLi wrapper documentation.
🎂 Support the development of this project
Your support is greatly appreciated and it keeps me motivated continue working on open source projects. If you enjoy this project please star it by clicking on the star button at the top of the page. If you're feeling generous, you can also buy me a coffee through PayPal or become a sponsor. Thank you for your support! 🎉
Requirements
PHP 7.4.0+ with the mysqli extension activated, MySQL 4.1.22+
The library itself still runs on PHP 5.6.40 and newer, and this is verified on every change with PHPCompatibility via
composer check-compat-legacy, and by linting and smoke-testing it on a real PHP 5.6.40 viatests/run-legacy.sh. The supported version is given as 7.4 because that is the oldest version the test suite runs on, and supported should mean tested. If you are on PHP 5.6.40 to 7.3 the library will very likely work, but you are on your own.
For using memcache as caching method, PHP must have the memcache extension installed. The memcache_compressed property, which hands the compressing over to memcache instead of doing it in the library, additionally requires that extension to have been built with zlib support
For using redis as caching method, PHP must have the redis extension installed. The redis_compressed property, which hands the compressing over to the extension instead of doing it in the library, additionally requires that extension to have been built with --enable-redis-lzf
Query results are compressed either way - the two _compressed properties only decide whether the library or the caching server does it, and caching works without either of them.
Installation
You can install Zebra Database via Composer
Or you can install it manually by downloading the latest version, unpacking it, and then including it in your project
How to use
Connecting to a database
Running queries
An INSERT statement
An UPDATE statement
There are over 40 methods and 20 properties that you can use and lots of things you can do with this library. I've prepared an awesome documentation so that you can easily get an overview of what can be done. Go ahead, check it out!
Running the tests
The test suite is not part of the released package - if you want to run them you need a git checkout of the repository.
The tests run against a real MySQL instance and drop and recreate their tables at the start of every
run - test_users, test_products and test_categories, in a database of their own - so point them at
a server you are happy for them to write to.
Running them wants MySQL 5.7 or newer - a requirement of the suite, not of the library, which still
supports 4.1.22+. What sets that floor is strict mode: the suite asserts what MySQL does with a value too
long for its column, and that is one thing under STRICT_TRANS_TABLES and quite another without it, so
rather than have tests that pass either way the requirement is checked before the first test runs and
reported if the server does not meet it. 5.7 is simply where strict mode became the default - an older
server will do if it is switched on there, and the tables themselves only need 5.5.3 for utf8mb4 - but
5.7 and up is what this is run against.
On Windows use tests\run-tests.bat, which does the same things in the same order.
Run it with no arguments and it checks everything - the suite, then the PHP compatibility, static analysis and coding standard checks. Give it any argument and it runs only the tests you asked for, which is what you want while working on something:
The suite needs PHP 7.4 or newer. The library goes back further than that, and tests/run-legacy.sh is
what backs that claim up - it lints everything that ships and round-trips a row on a real PHP 5.6.40 in a
container, against a MySQL of its own, so it needs Docker running:
The three checks are also available on their own, and those are the ones to reach for while working through whatever they report, since they take arguments of their own:
A handful of tests cover the memcache and redis caching backends and skip themselves unless both the extension and a running server are found. Neither needs any configuration:
Two of those go further and skip unless the redis extension was built with --enable-redis-lzf, since what
they check is that compression is handed over to the extension rather than done twice. All of them run on
every push through GitHub Actions,
against PHP 7.4 through 8.5 with both servers alongside.
Coverage is not produced on an ordinary run. Asking for it requires either pcov or Xdebug to be installed - without one of them PHPUnit reports "No code coverage driver available", runs the tests anyway and writes no report:
All versions of zebra_database with dependencies
ext-mysqli Version *