Changeset 2089

Show
Ignore:
Timestamp:
09/21/07 17:18:23 (16 months ago)
Author:
david
Message:

support for setting attributes on a connection, use param "attributes" as an array (name => value like "AUTO_LENGTH_VLD", without Doctrine::ATTR_) and "bind_components", an array of component names to bind to this connection

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/src/database/AgaviDoctrineDatabase.class.php

    r2086 r2089  
    8080    parent::initialize($databaseManager, $parameters); 
    8181     
     82    $name = $this->getName(); 
     83     
    8284    // try to autoload doctrine 
    8385    if(!class_exists('Doctrine')) { 
     
    106108      } 
    107109       
    108       $this->connection = $this->doctrineManager->openConnection($dsn, $this->getName()); 
     110      $this->connection = $this->doctrineManager->openConnection($dsn, $name); 
    109111      // do not assign the resource here. that would connect to the database 
    110112      // $this->resource = $this->connection->getDbh(); 
     113       
     114      foreach((array)$this->getParameter('attributes', array()) as $attributeName => $attributeValue) { 
     115        $this->connection->setAttribute($attributeName, $attributeValue); 
     116      } 
     117       
     118      foreach((array)$this->getParameter('bind_components', array()) as $componentName) { 
     119        $this->doctrineManager->bindComponent($componentName, $name); 
     120      } 
    111121    } catch(Doctrine_Exception $e) { 
    112122      // the connection's foobar'd