예제 #1
0
파일: example.php 프로젝트: majestixx/bav
 * edit the PDO object to create a valid DBS connection.
 */
use malkusch\bav\PDODataBackendContainer;
try {
    /*
     * Create the PDO container. If you intend to do so you should
     * create the file bav/configuration.php and return a Configuration which
     * uses PDODataBackendContainer.
     * 
     * @see ConfigurationRegistry
     */
    //     $backendContainer = new PDODataBackendContainer(
    //         new \PDO('sqlite::memory:')
    //     );
    //     $backend = $backendContainer->getDataBackend();
    $backend = $bav->getDataBackend();
    /**
     * We can use an arbitrary SQL statement to search for some agencies. This statement
     * needs at least to return the ids of the agencies.
     */
    $agencies = $backend->getAgencies("SELECT id FROM {$backend->getPrefix()}agency LIMIT 10");
    foreach ($agencies as $agency) {
        echo "Found agency {$agency->getPostcode()} of bank {$agency->getBank()->getBankID()}\n";
    }
    /**
     * You perform better if you provide all attributes of the agency table. Let's
     * try it and search all banks in munich.
     */
    $agencies = $backend->getAgencies("SELECT * FROM {$backend->getPrefix()}agency\n           WHERE city='München'\n           GROUP BY bank");
    foreach ($agencies as $agency) {
        echo "{$agency->getBank()->getBankID()} ({$agency->getName()}, {$agency->getCity()})\n";