Download the PHP package mehedimi/wp-query-builder without Composer

On this page you can find all versions of the php package mehedimi/wp-query-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-query-builder

WP Query Builder

WP Query Builder

WP Query Builder is package for developers, which can simplify query writing experience in WordPress.

Installation

If you need extra feature of WP Query Builder then you may install WP Query Builder Extension Package

Then require the autoload file of composer into your theme or plugin file.

Running SQL Queries

The DB class provides methods for each type of query: select, insert, update, delete, statement and affectingStatement.

Running A Select Query

To run a basic SELECT query, you may use the select method on the DB class:

Running An Insert Statement

To execute an insert statement, you may use the insert method on the DB class. Like select, this method accepts the SQL query as its first argument and bindings as its second argument:

Running An Update Statement

Running A Delete Statement

Running Database Queries

Retrieving All Rows From A Table

You may use the table method provided by the DB class to begin a query. The table method returns a fluent query builder instance for the given table, allowing you to chain more constraints onto the query and then finally retrieve the results of the query using the get method:

Retrieving A Single Row

If you just need to retrieve a single row from a database table, you may use the first method of DB class. This method will return a single stdClass object:

Aggregates

The query builder also provides a variety of methods for retrieving aggregate values like count, max, min, avg, and sum. You may call any of these methods after constructing your query:

Of course, you may combine these methods with other clauses to fine-tune how your aggregate value is calculated:

Specifying A Select Clause

You may not always want to select all columns from a database table. Using the select method, you can specify a custom "select" clause for the query:

The distinct method allows you to force the query to return distinct results:

Joins

Inner Join Clause

The query builder may also be used to add join clauses to your queries. To perform a basic "inner join", you may use the join method on a query builder instance. The first argument passed to the join method is the name of the table you need to join to, while the remaining arguments specify the column constraints for the join. You may even join multiple tables in a single query:

Left Join / Right Join Clause

If you would like to perform a "left join" or "right join" instead of an "inner join", use the leftJoin or rightJoin methods. These methods have the same signature as the join method:

Advanced Join Clauses

You may also specify more advanced join clauses. To get started, pass a closure as the second argument to the join method. The closure will receive a Mehedi\WPQueryBuilder\Query\Join instance which allows you to specify constraints on the "join" clause:

If you would like to use a "where" clause on your joins, you may use the where and orWhere methods provided by the Join instance. Instead of comparing two columns, these methods will compare the column against a value:

Basic Where Clauses

Where Clauses

You may use the query builder's where method to add "where" clauses to the query. The most basic call to the where method requires three arguments. The first argument is the name of the column. The second argument is an operator, which can be any of the database's supported operators. The third argument is the value to compare against the column's value.

For example, the following query retrieves users where the value of the votes column is equal to 100 and the value of the age column is greater than 35:

For convenience, if you want to verify that a column is = to a given value, you may pass the value as the second argument to the where method. Laravel will assume you would like to use the = operator:

As previously mentioned, you may use any operator that is supported by your database system:

Or Where Clauses

When chaining together calls to the query builder's where method, the "where" clauses will be joined together using the and operator. However, you may use the orWhere method to join a clause to the query using the or operator. The orWhere method accepts the same arguments as the where method:

Where Nested

If you need to group where condition within parentheses, you may use the whereNested method

The example above will produce the following SQL:

Additional Where Clauses

whereBetween

The whereBetween method verifies that a column's value is between two values:

whereNotBetween

The whereNotBetween method verifies that a column's value lies outside of two values:

whereIn / whereNotIn

The whereIn method verifies that a given column's value is contained within the given array:

The whereNotIn method verifies that the given column's value is not contained in the given array:

whereNull / whereNotNull

The whereNull method verifies that the value of the given column is NULL:

The whereNotNull method verifies that the column's value is not NULL:

whereColumn / orWhereColumn

The whereColumn method may be used to verify that two columns are equal:

You may also pass a comparison operator to the whereColumn method:

Ordering, Grouping, Limit & Offset

Ordering

The orderBy Method

The orderBy method allows you to sort the results of the query by a given column. The first argument accepted by the orderBy method should be the column you wish to sort by, while the second argument determines the direction of the sort and may be either asc or desc:

To sort by multiple columns, you may simply invoke orderBy as many times as necessary:

Grouping

The groupBy Method

As you might expect, the groupBy method may be used to group the query results:

Limit & Offset

You may use the offset and limit methods to limit the number of results returned from the query or to skip a given number of results in the query:

Database Transactions

You may use the transaction method provided by the DB class to run a set of operations within a database transaction. If an exception is thrown within the transaction closure, the transaction will automatically be rolled back. If the closure executes successfully, the transaction will automatically be committed. You don't need to worry about manually rolling back or committing while using the transaction method:

Manually Using Transactions

If you would like to begin a transaction manually and have complete control over rollbacks and commits, you may use the beginTransaction method provided by the DB facade:

You can rollback the transaction via the rollback method:

Lastly, you can commit a transaction via the commit method:

Note
All the 4 methods support $flags and $name parameter supported by mysqli, like bellow:

Defining Relationships

You could define your relationship on query time.

One To One

A one-to-one relationship is a very basic type of database relationship. For example, a post might be associated with one postmeta called color. To define this relationship, we need to just call withOne method on query builder

This will return all posts with color. Let's say you have two posts and each post have one postmeta row. So output of this query will be like bellow

And executes following those queries.

One To Many

A one-to-many relationship is used to define relationships where a single item has one or more child item. For example, a post may have an infinite number of comments. To use One-To-Many relation in Query Builder just use withMany method.

Sample output will be like bellow

And execute following two queries


All versions of wp-query-builder with dependencies

PHP Build Version
Package Version
Requires ext-mysqli Version *
php Version >=5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mehedimi/wp-query-builder contains the following files

Loading the files please wait ....