Overview
  • Namespace
  • Class

Namespaces

  • MatthiasWeb
    • RealMediaLibrary
      • api
      • attachment
      • base
      • comp
        • complexquery
      • folder
      • general
      • metadata
      • order
      • rest
      • usersettings
  • None

Classes

  • ComplexQuery
  • ResetNames

Class ComplexQuery

Define your complex SQL query. When implementing your complex query do not use global $wpdb; in your methods. Use ::getWpdb() instead.

A complex query can be splitted into three parts:

  • 1. Single Query: The query can be processed through one single SQL query with user defined variables
  • 2. Procedure: The procedure can write for example to an temporary table and reads again from this one
  • 3. Fallback: The fallback can throw an error or do the query through PHP functions
MatthiasWeb\RealMediaLibrary\base\Base
Extended by MatthiasWeb\RealMediaLibrary\comp\complexquery\ComplexQuery

Direct known subclasses

MatthiasWeb\RealMediaLibrary\comp\complexquery\ResetNames

Abstract
Namespace: MatthiasWeb\RealMediaLibrary\comp\complexquery
Example: $rows = new MyComplexQuery($wpdb)->getResults();
Located at comp/complexquery/ComplexQuery.class.php

Methods summary

public
# __construct( $wpdb )
public
# getResult( )

Get the result from the three different result types: singleQuery, procedure or fallback.

Get the result from the three different result types: singleQuery, procedure or fallback.

Returns

mixed
abstract public
# singleQuery( )

This function is called when user defined variables are support. This method should return your expected result. It works with both mysqli_connect and mysql_connect.

This function is called when user defined variables are support. This method should return your expected result. It works with both mysqli_connect and mysql_connect.

See

this::isSingleQueriableWithUserDefinedVars()

Returns

mixed
abstract public
# procedure( )

This function is called when procedures (stored functions and procedures) are available. It is also necessery that mysqli is in use. mysql_connect does not support store_results() method. This method should return your expected result. You should work with this::hasProcedure() to install your procedure if not exists.

This function is called when procedures (stored functions and procedures) are available. It is also necessery that mysqli is in use. mysql_connect does not support store_results() method. This method should return your expected result. You should work with this::hasProcedure() to install your procedure if not exists.

Note: A procedure can for example write into a temporary table and reads from it again.

See

this::isProcedurable()
this::hasProcedure()
this::install()
this::getProcedureResults()

Returns

mixed
abstract public
# fallback( )

This function is called when a single query is not possible and procedures are not allowed.

This function is called when a single query is not possible and procedures are not allowed.

Returns

mixed
final public
# install( callable $callable )

Start an installer. Use this function in your procedure() method.

Start an installer. Use this function in your procedure() method.

Parameters

$callable
The callable to install the procedure for example
final protected
# getProcedureResults( string $sql, boolean $returnTrue = false )

Call a "CALL proc" SQL and parse the results.

Call a "CALL proc" SQL and parse the results.

Parameters

$sql
The SQL string to execute
$returnTrue
When the CALL is successfully and has no results then return true instead of an empty array

Returns

Array or false when an error occured
public
# hasProcedure( $procedure )

Checks if a given procedure is available for the current user.

Checks if a given procedure is available for the current user.

Returns

boolean
public
# isSingleQueriableWithUserDefinedVars( )

Checks if a single query is allowed to use @vars. For example MariaDB does not resolve @vars in a single query when they are not declared before. This method uses a cache (30 days).

Checks if a single query is allowed to use @vars. For example MariaDB does not resolve @vars in a single query when they are not declared before. This method uses a cache (30 days).

Returns

boolean
public
# isProcedurable( )

Checks if procedures are allowed. This function uses a cache (30 days).

Checks if procedures are allowed. This function uses a cache (30 days).

See

https://stackoverflow.com/questions/609855/check-user-rights-before-attempting-to-create-database

Returns

boolean
final public
# _isProcedurable( )
public
# isMysqli( )

Checks if the database handle is mysqli or not.

Checks if the database handle is mysqli or not.

Returns

boolean
public
# getWpdb( )
public
# getDbh( )
public
# getCache( )

Methods inherited from MatthiasWeb\RealMediaLibrary\base\Base

debug(), getCore(), getTableName()

Constants summary

string CACHE_OPTION_NAME
# "mw_complex_query"
API documentation generated by ApiGen