Example #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;
 }
Example #2
0
 /**
  * Returns all currently stored values in the LUT cache.
  * @param \System\Db\Database The database to query
  * @return \System\Db\DatabaseResult A resultset with all the results.
  */
 public static final function getCache(\System\Db\Database $db)
 {
     $query = new \System\Db\Query($db, \System\Cache\LUTCache\SQL_LUTCACHE_RETRIEVE_ALL);
     $results = $db->query($query);
     return $results;
 }
Example #3
0
 /**
  * Returns a Vector with all table column names from the requested table
  * @param \System\Db\Database the database to query
  * @param string The tablename to retrieve the columns from
  * @return \System\Collection\Vector a Vector containing all the column names
  */
 public static final function getTableColumnNames(\System\Db\Database $db, $tableName)
 {
     $query = new \System\Db\Query($db, 'SHOW COLUMNS FROM %?%');
     $query->bind($tableName, \System\Db\QueryType::TYPE_QUERY);
     $results = $db->query($query);
     $columnNames = new \System\Collection\Vector();
     foreach ($results as $result) {
         $columnNames[] = $result->Field;
     }
     return $columnNames;
 }
Example #4
0
 /**
  * Iterates through the given resultset, dispatching every single mail with the given priority.
  * @param \System\Db\Database The database to use for the emailsystem queue
  * @param SMTP The smtp to use
  * @param \System\Db\DatabaseResult The results to iterate
  * @param int The priority level
  */
 private static final function iterateMailResults(\System\Db\Database $db, \System\Email\SMTP $smtp, \System\Db\DatabaseResult $results, $priority)
 {
     foreach ($results as $result) {
         $attachQuery = new \System\Db\Query($db, \System\Email\SQL_EMAILSYSTEM_GET_ATTACH);
         $attachQuery->bind($result->id, \System\Db\QueryType::TYPE_INTEGER);
         $attachQuery->bind($priority, \System\Db\QueryType::TYPE_INTEGER);
         $attachments = $db->query($attachQuery);
         self::addToLog('Processing ' . $results->count() . ' ' . self::$priorityNames[$priority][0] . ' priority mails');
         self::dispatchSingleMail($smtp, $result->from, self::convertAddressStringToArray($result->to), self::convertAddressStringToArray($result->cc), self::convertAddressStringToArray($result->bcc), $result->subject, $result->message, $attachments);
         $query = new \System\Db\Query($db, \System\Email\SQL_EMAILSSYTEM_DELETEMAIL);
         $query->bind(self::$priorityNames[$priority][1], \System\Db\QueryType::TYPE_QUERY);
         $query->bind($result->id, \System\Db\QueryType::TYPE_INTEGER);
         $db->query($query);
         $query = new \System\Db\Query($db, \System\Email\SQL_EMAILSYSTEM_DELETEATTACH);
         $query->bind($result->id, \System\Db\QueryType::TYPE_INTEGER);
         $query->bind($priority, \System\Db\QueryType::TYPE_INTEGER);
         $db->query($query);
     }
 }
Example #5
0
 /**
  * Delete an onetimecall. This invalidates the object in the db.
  * @param \System\Db\Database The database to query
  * @return null so we stop the chaining
  */
 public final function delete(\System\Db\Database $db)
 {
     $query = new \System\Db\Query($db, SQL_ONETIMECALL_DELETE);
     $query->bind($this->getId(), \System\Db\QueryType::TYPE_INTEGER);
     $db->query($query);
     return null;
 }