Overview

Namespaces

  • None
  • RedBeanPHP
    • Adapter
    • BeanHelper
    • Cursor
    • Driver
    • Logger
      • RDefault
    • QueryWriter
    • RedException
    • Repository
    • Util

Classes

  • R
  • RedBean_SimpleModel
  • RedBeanPHP\Adapter\DBAdapter
  • RedBeanPHP\AssociationManager
  • RedBeanPHP\BeanCollection
  • RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper
  • RedBeanPHP\Cursor\NullCursor
  • RedBeanPHP\Cursor\PDOCursor
  • RedBeanPHP\Driver\RPDO
  • RedBeanPHP\DuplicationManager
  • RedBeanPHP\Facade
  • RedBeanPHP\Finder
  • RedBeanPHP\Jsonable
  • RedBeanPHP\LabelMaker
  • RedBeanPHP\Logger\RDefault
  • RedBeanPHP\Logger\RDefault\Debug
  • RedBeanPHP\Observable
  • RedBeanPHP\OODB
  • RedBeanPHP\OODBBean
  • RedBeanPHP\QueryWriter\AQueryWriter
  • RedBeanPHP\QueryWriter\CUBRID
  • RedBeanPHP\QueryWriter\MySQL
  • RedBeanPHP\QueryWriter\PostgreSQL
  • RedBeanPHP\QueryWriter\SQLiteT
  • RedBeanPHP\R
  • RedBeanPHP\Repository
  • RedBeanPHP\Repository\Fluid
  • RedBeanPHP\Repository\Frozen
  • RedBeanPHP\SimpleModel
  • RedBeanPHP\SimpleModelHelper
  • RedBeanPHP\TagManager
  • RedBeanPHP\ToolBox
  • RedBeanPHP\Util\ArrayTool
  • RedBeanPHP\Util\DispenseHelper
  • RedBeanPHP\Util\Dump
  • RedBeanPHP\Util\MultiLoader
  • RedBeanPHP\Util\Transaction

Interfaces

  • RedBeanPHP\Adapter
  • RedBeanPHP\BeanHelper
  • RedBeanPHP\Cursor
  • RedBeanPHP\Driver
  • RedBeanPHP\Logger
  • RedBeanPHP\Observer
  • RedBeanPHP\Plugin
  • RedBeanPHP\QueryWriter

Exceptions

  • RedBeanPHP\RedException
  • RedBeanPHP\RedException\SQL

Functions

  • array_flatten
  • dmp
  • EID
  • genslots
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace RedBeanPHP\Util;
 4: 
 5: use RedBeanPHP\OODB as OODB;
 6: use RedBeanPHP\OODBBean as OODBBean;
 7: use RedBeanPHP\RedException as RedException;
 8: 
 9: /**
10:  * Array Tool Helper
11:  *
12:  * This code was originally part of the facade, however it has
13:  * been decided to remove unique features to service classes like
14:  * this to make them available to developers not using the facade class.
15:  *
16:  * This is a helper or service class containing frequently used
17:  * array functions for dealing with SQL queries.
18:  * 
19:  * @file    RedBeanPHP/Util/ArrayTool.php
20:  * @author  Gabor de Mooij and the RedBeanPHP Community
21:  * @license BSD/GPLv2
22:  *
23:  * @copyright
24:  * copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
25:  * This source file is subject to the BSD/GPLv2 License that is bundled
26:  * with this source code in the file license.txt.
27:  */
28: class ArrayTool
29: {
30:     /**
31:      * Generates question mark slots for an array of values.
32:      *
33:      * @param array  $array array to generate question mark slots for
34:      *
35:      * @return string
36:      */
37:     public static function genSlots( $array, $template = NULL )
38:     {
39:         $str = count( $array ) ? implode( ',', array_fill( 0, count( $array ), '?' ) ) : '';
40:         return ( is_null( $template ) ||  $str === '' ) ? $str : sprintf( $template, $str );
41:     }
42: 
43:     /**
44:      * Flattens a multi dimensional bindings array for use with genSlots().
45:      *
46:      * @param array $array  array to flatten
47:      * @param array $result result array parameter (for recursion)
48:      *
49:      * @return array
50:      */
51:     public static function flat( $array, $result = array() )
52:     {       
53:         foreach( $array as $value ) {
54:             if ( is_array( $value ) ) $result = self::flat( $value, $result );
55:             else $result[] = $value;
56:         }
57:         return $result;
58:     }
59: }
60: 
API documentation generated by ApiGen