Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/10quality/wp-query-builder
WordPress SQL query builder library for custom models and data querying.
https://github.com/10quality/wp-query-builder
Last synced: 5 days ago
JSON representation
WordPress SQL query builder library for custom models and data querying.
- Host: GitHub
- URL: https://github.com/10quality/wp-query-builder
- Owner: 10quality
- License: mit
- Created: 2019-09-17T00:23:26.000Z (about 5 years ago)
- Default Branch: v1.0
- Last Pushed: 2023-02-25T18:27:28.000Z (over 1 year ago)
- Last Synced: 2024-10-26T13:42:20.749Z (23 days ago)
- Language: PHP
- Homepage: https://www.wordpress-mvc.com/
- Size: 55.7 KB
- Stars: 35
- Watchers: 6
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wordpress Query Builder Library
[![Latest Stable Version](https://poser.pugx.org/10quality/wp-query-builder/v/stable)](https://packagist.org/packages/10quality/wp-query-builder)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/10quality/wp-query-builder/test.yml)
[![Total Downloads](https://poser.pugx.org/10quality/wp-query-builder/downloads)](https://packagist.org/packages/10quality/wp-query-builder)
[![License](https://poser.pugx.org/10quality/wp-query-builder/license)](https://packagist.org/packages/10quality/wp-query-builder)This package provides a SQL query builder class built on top of WordPress core Database accessor. Usability is similar to Laravel's Eloquent.
The library also provides an abstract class and a trait to be used on data models built for custom tables. The abstract class extends our generic [PHP model](https://github.com/10quality/php-data-model) class.
This is the perfect package to use within the [WordPress MVC](https://www.wordpress-mvc.com/) framework.
## Install
This package / library requires composer.
```bash
composer require 10quality/wp-query-builder
```## Usage & Documentation
Please read the [wiki](https://github.com/10quality/wp-query-builder/wiki) for documentation.
Quick snippet sample:
```php
$books = wp_query_builder()
->select( 'ID' )
->select( 'post_name AS name' )
->from( 'posts' )
->where( ['post_type' => 'book'] )
->get();foreach ( $books as $book ) {
echo $book->ID;
echo $book->name;
}
```## Coding Guidelines
PSR-2 coding guidelines.
## License
MIT License (c) 2019 [10 Quality](https://www.10quality.com/).