| core_db

# Class: Bs_ArrayDb Source Location: /core/db/Bs_ArrayDb.class.php
### Class Overview
    Bs_Object
       |
       --Bs_ArrayDb
Array-DB class. makes it possible to execute sql queries on a array. #### Author(s): andrej arn <at blueshoes dot org> #### Version: 4.0.$Revision: 1.2 $ #### Copyright: blueshoes.org | ### Variables $_bsDb | ### Methods Bs_ArrayDb init query
### Inherited Variables | ### Inherited Methods #### Class: Bs_Object Bs_Object::Bs_Object() Bs_Object::getErrors() Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack. Bs_Object::getLastError() Basic error handling: Get last error string from the global Bs_Error-error stack. Bs_Object::getLastErrors() Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors(). Bs_Object::persist() Persists this object by serializing it and saving it to a file with unique name. Bs_Object::setError() Basic error handling: Push an error string on the global Bs_Error-error stack. Bs_Object::toHtml() Dumps the content of this object to a string using PHP's var_dump(). Bs_Object::toString() Dumps the content of this object to a string using PHP's var_dump(). Bs_Object::unpersist() Fetches an object that was persisted with persist()
### Class Details [line 56] Array-DB class. makes it possible to execute sql queries on a array. ever had a structured array and wanted to remove some elements, add some, and order it by multiple columns? it's a nap using this class. This class requires a connection (set in global.conf.php) to a running db (e.g. MySQL).

    1     // -------------------------------------------------------------------
    2      example usage:
    3      $array = array(
    4        array('name' => 'folfgang hoelzl',  'birthday' => '31.12.1925', 'city' => 'wien',         'bikes' => 7),
    5        array('name' => 'alanis morisette', 'birthday' => '09.05.1930', 'city' => 'vancouver',    'bikes' => 1),
    6        array('name' => 'tom jones',        'birthday' => '05.01.1983', 'city' => 'miami',        'bikes' => 0),
    7        array('name' => 'super man',        'birthday' => '25.12.1964', 'city' => 'hongkong',     'bikes' => 2),
    8      );
    9      $adb =& new Bs_ArrayDb();
    10     $status = $adb->init($array);
    11     if ($status) {
    12       dump($adb->query("select *  from [array] WHERE bikes >= 1"));
    13     }
    14     //that is my output:
    15     array(3) {
    16       [0]=>&array(4) {
    17         ["name"]=>  string(16) "folfgang hoelzl"
    18         ["birthday"]=>  string(10) "31.12.1925"
    19         ["city"]=>  string(9) "wien"
    20         ["bikes"]=>  string(1) "7"
    21       }
    22       [1]=>&array(4) {
    23         ["name"]=>  string(12) "alanis morisette"
    24         ["birthday"]=>  string(10) "09.05.1930"
    25         ["city"]=>  string(6) "vancouver"
    26         ["bikes"]=>  string(1) "1"
    27       }
    28       [2]=>&array(4) {
    29         ["name"]=>  string(9) "super man"
    30         ["birthday"]=>  string(10) "25.12.1964"
    31         ["city"]=>  string(12) "hongkong"
    32         ["bikes"]=>  string(1) "2"
    33       }
    34     }
    35
#### Tags:
pattern: | singleton: (pseudostatic)
access: | public
version: | 4.0.$Revision: 1.2 $
copyright: | blueshoes.org
author: | andrej arn <at blueshoes dot org>
[ Top ] ### Class Variables #### $_bsDb = [line 69] the db object that is in use.
Type: | mixed
[ Top ] ### Class Methods ### constructor Bs_ArrayDb [line 84]
`Bs_ArrayDb Bs_ArrayDb( )`
constructor. [ Top ] ### method init [line 94]
`bool init( array $data)`
inits the object with the given data. #### Tags:
return: | (TRUE on success and the object is ready to take queries, FALSE otherwise.)
#### Parameters:
array | $data |
[ Top ] ### method query [line 124]
`mixed query( string $sqlQuery)`
executes the given sql query on your data. examples: "select * from [array]" "select * from [array] WHERE bikes >= 1" as you can see you need to call the table name '[array]'. #### Tags:
return: | (hrm...)
access: | public
#### Parameters:
string | $sqlQuery |
[ Top ] Documentation generated on Mon, 29 Dec 2003 21:08:03 +0100 by phpDocumentor 1.2.3