Пример #1
0
 /**
  *
  * @param $id: l'id di una Maildirectory.
  */
 static function loadDirectory($id)
 {
     return MailDirectory::loadFromDatabase($id);
 }
Пример #2
0
 private static function loadDirectoriesFrom($data)
 {
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineMailColumns();
         $table = Query::getDBSchema()->getTable(TABLE_MAIL_DIRECTORY);
         $wheres = array();
         foreach ($data as $comumnname => $d) {
             $wheres[] = new WhereConstraint($table->getColumn($comumnname), Operator::EQUAL, $d);
         }
         $rs = $db->execute($s = Query::generateSelectStm(array($table), array(), $wheres, array()), $table->getName(), $data);
         //echo "<p>" . $s . "</p>"; //DEBUG
         //echo "<p>" . $db->num_rows() . "</p>"; //DEBUG
         if ($db->num_rows() > 0) {
             $dirs = array();
             while ($row = $db->fetch_result()) {
                 $d = new MailDirectory($row[MAIL_DIRECTORY_NAME], $row[MAIL_DIRECTORY_OWNER]);
                 $d->setID(intval($row[MAIL_DIRECTORY_ID]))->loadMails();
                 //echo "<p>" .$d ."</p>";
                 $dirs[] = $d;
             }
             return $dirs;
         } else {
             $db->display_error("MailDirectory::loadDirectoriesFrom()");
         }
     } else {
         $db->display_connect_error("MailDirectory::loadDirectoriesFrom()");
     }
     return false;
 }