Download the PHP package gin0115/pixie-wpdb without Composer
On this page you can find all versions of the php package gin0115/pixie-wpdb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gin0115/pixie-wpdb
More information about gin0115/pixie-wpdb
Files in gin0115/pixie-wpdb
Package pixie-wpdb
Short Description An adaptation of Pixie (created byusmanhalalit) for WordPress using WPDB over PDO.
License MIT
Homepage https://github.com/gin0115/pixie-wpdb
Informations about the package pixie-wpdb
Pixie WPDB Query Builder for WordPress
An expressive, query builder for WordPRess it can also be referred as a Database Abstraction Layer. Pixie WPDB supports WPDB ONLY and it takes care of query sanitization, table prefixing and many other things with a unified API.
Pixie WPDB is an adaption of
pixie
originally written by usmanhalalit. Pixie is no longer under active development.
Features
- Fluent API
- Nested Queries
- Multiple Connections
- Sub Queries
- JSON Support
- Model Hydration
- Custom Alias Facade
- Raw SQL Expressions
- Value Type Binding
- Transaction Support
- Query Events
Install
Perquisites
- WordPress 5.7+ (tested upto 5.9)
- PHP 7.1+ (includes support for PHP8)
- MySql 5.7+ or MariaDB 10.2+
- Composer (optional)
Using Composer
The easiest way to include Pixie in your project is to use composer.
Static Loader
If you are planning to just inlcude Pixie direct in your plugin, you can extract the src
directory and add this to your functions.php
or similar.
Each class is checked if already loaded, to avoid conflicts if used on multiple plugins.
Setup Connection
If you are only planning on having a single connection, you will only need to configure the connection once.
This would then give access to an instance of the QueryBuilder using this connection, via the alias defined Gin0115\DB
Generated & executed query :: "SELECT * FROM gin0115_foo WHERE column = 'red'; "
Connection Config
It is possible to configure the connection used by your instance of the query builder.
Values
Key | Constant | Value | Description |
---|---|---|---|
prefix | Connection:: PREFIX | STRING | Custom table prefix (will ignore WPDB prefix) |
use_wpdb_prefix | Connection:: USE_WPDB_PREFIX | BOOL | If true will use WPDB prefix and ignore custom prefix |
clone_wpdb | Connection:: CLONE_WPDB | BOOL | If true, will clone WPDB to not use reference to the instance (usually the $GLOBAL) |
show_errors | Connection:: SHOW_ERRORS | BOOL | If set to true will configure WPDB to show/hide errors |
Connection Alias
When you create a connection:
MyAlias
is the name for the class alias you want to use (like MyAlias::table(...)
), you can use whatever name (with Namespace also, MyNamespace\\MyClass
) you like or you may skip it if you don't need an alias. Alias gives you the ability to easily access the QueryBuilder class across your application.
Usage
Once a connection is created, the builder can be accessed either directly using the Alias Facade or by creating an instance.
Static Usage
The easiest way to use Pixie is to use the alias facade provided. This allows you to access a builder instance anywhere, much like WPDB.
None Static Usage
When not using an alias you can instantiate the QueryBuilder handler separately, helpful for Dependency Injection and Testing.
$connection
here is optional, if not given it will always associate itself to the first connection, but it can be useful when you have multiple database connections.
Credits
This package began as a fork of Pixie originally written by usmanhalalit A few features have been inspired by the Pecee-pixie fork and continuation, especially the extended aggregate methods.
Changelog
- 0.0.3 - More improvements to the
updateOrInsert()
method. - 0.0.2 - Improvements to the
updateOrInsert()
method - 0.0.1 - Various external and interal changes made to the initial code written by Muhammad Usman
If you find any typo then please edit and send a pull request.
© 2022 Glynn Quelch. Licensed under MIT license.