/** * Creates a new DbLookup object. * @param Database The database to create the connection in. This should be the DbLookup pool * @param string The unique name of the DbLookup entry * @param string The server or db host * @param string The connection user * @param string The connection password * @param string The name of the database used * @param int The port for the database connection * @param bool True to use persistant connections * @return DbLookup The newly created DbLookup object */ public static final function create(\System\Db\Database $db, $name, $dbServer, $dbUser, $dbPassword, $dbName, $dbPort = self::DB_PORT_DEFAULT, $persistent = self::DB_PERSISTANT_DEFAULT) { $previousAutocommit = $db->getAutocommit(); $db->setAutocommit(false); $query = new \System\Db\Query($db, SQL_DBLOOKUP_CREATE); $query->bind($name, \System\Db\QueryType::TYPE_STRING); $db->query($query); $insertId = $db->getInsertId(); $dbLookup = self::loadPrimary($db, $insertId); assert($dbLookup); $dbLookup->setDbName($dbName)->setDbServer($dbServer)->setDbUser($dbUser)->setDbPassword($dbPassword)->setDbPort($dbPort)->setDbPersistent($persistent); $dbLookup->storePrimary(); $db->setAutocommit($previousAutocommit); return $dbLookup; }