\RedBeanPHP\UtilArrayTool

Array Tool Helper

This code was originally part of the facade, however it has been decided to remove unique features to service classes like this to make them available to developers not using the facade class.

This is a helper or service class containing frequently used array functions for dealing with SQL queries.

Summary

Methods
Properties
Constants
genSlots()
flat()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

genSlots()

genSlots(array  $array, string  $template = NULL) : string

Generates question mark slots for an array of values.

Given an array and an optional template string this method will produce string containing parameter slots for use in an SQL query string.

Usage:

R::genSlots( array( 'a', 'b' ) );

The statement in the example will produce the string: '?,?'.

Another example, using a template string:

R::genSlots( array('a', 'b'), ' IN( %s ) ' );

The statement in the example will produce the string: ' IN( ?,? ) '.

Parameters

array $array

array to generate question mark slots for

string $template

template to use

Returns

string

flat()

flat(array  $array, array  $result = array()) : array

Flattens a multi dimensional bindings array for use with genSlots().

Usage:

R::flat( array( 'a', array( 'b' ), 'c' ) );

produces an array like: [ 'a', 'b', 'c' ]

Parameters

array $array

array to flatten

array $result

result array parameter (for recursion)

Returns

array