/** * Overrides the parent setAttribute to support the isSlowOnly attribute. * * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value */ public function setAttribute($attribute, $value) { switch ($attribute) { case 'isSlowOnly': // Set whether the connection must only log slow queries. // The slow threshold must be set on the profiler (100ms by default). $this->isSlowOnly = $value; break; default: parent::setAttribute($attribute, $value); } }
public function build($dsn = null, $user = null, $pass = null, $adapter = null, array $classTargets = null) { if (null === $dsn) { $dsn = 'sqlite::memory:'; } if (null === $adapter) { $adapter = new SqliteAdapter(); } if (null === $classTargets) { $classTargets = $this->classTargets; } $pdo = new PdoConnection($dsn, $user, $pass); $con = new ConnectionWrapper($pdo); $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING); $adapter->initConnection($con, []); $this->buildSQL($con); $this->buildClasses($classTargets); $name = $this->getDatabase()->getName(); Propel::getServiceContainer()->setAdapter($name, $adapter); Propel::getServiceContainer()->setConnection($name, $con); return $con; }
public function build($dsn = null, $user = null, $pass = null, $adapter = null) { if (null === $dsn) { $dsn = 'sqlite::memory:'; } if (null === $adapter) { $adapter = new \Propel\Runtime\Adapter\Pdo\SqliteAdapter(); } $pdo = new PdoConnection($dsn, $user, $pass); $con = new ConnectionWrapper($pdo); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $this->buildSQL($con); $this->buildClasses(); $name = $this->getDatabase()->getName(); Propel::getServiceContainer()->setAdapter($name, $adapter); Propel::getServiceContainer()->setConnection($name, $con); return $con; }