Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * Attaches the emailattachments to the system in the queue
  *
  * @param \System\Db\Database The database to use
  * @param EmailMessage The email
  * @param int The priority of the mail
  */
 private static final function processAttachments(\System\Db\Database $database, \System\Email\EmailMessage $email, $priority)
 {
     $attachments = $email->getAttachments();
     $mailId = $database->getInsertId();
     foreach ($attachments as $attachment) {
         if ($attachment->exists()) {
             $data = base64_encode($attachment->getContents());
             $filename = $attachment->getFilename();
             $mimetype = $attachment->getMimeType();
             $query = new \System\Db\Query($database, \System\Email\SQL_EMAILSYSTEM_ADD_ATTACH);
             $query->bind($data, \System\Db\QueryType::TYPE_STRING);
             $query->bind($filename, \System\Db\QueryType::TYPE_STRING);
             $query->bind($mimetype, \System\Db\QueryType::TYPE_STRING);
             $query->bind($mailId, \System\Db\QueryType::TYPE_INTEGER);
             $query->bind($priority, \System\Db\QueryType::TYPE_INTEGER);
             $database->query($query);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Create a new onetimecall
  * @param \System\Db\Database The database to query
  * @param string The key which we should use to find the appropriate callback
  * @param string The value to reference the object with
  * @return \Module\Onetimecall\Onetimecall the newly created instance
  */
 public static function create(\System\Db\Database $db, $key, $value)
 {
     $hash = new \System\Security\Hash();
     $hash->addString(\System\Calendar\Time::now());
     $token = $hash->getHash();
     $query = new \System\Db\Query($db, SQL_ONETIMECALL_CREATE);
     $query->bind($token, \System\Db\QueryType::TYPE_STRING);
     $query->bind($key, \System\Db\QueryType::TYPE_STRING);
     $query->bind((string) $value, \System\Db\QueryType::TYPE_STRING);
     $db->query($query);
     $insertId = $db->getInsertId();
     return \Module\Onetimecall\Onetimecall::loadPrimary($db, $insertId);
 }