public function __construct($strHostName, $strDatabaseName, $strUsername, $strPassword)
 {
     $this->strHostName = $strHostName;
     $this->strDatabaseName = $strDatabaseName;
     $this->strUsername = $strUsername;
     $this->strPassword = $strPassword;
     LoadDriver::AddDataConnection($this);
 }
 public static function LoadByIdContestEntry($intidFormAnswer)
 {
     $sql = sprintf("SELECT * FROM %s WHERE idContestEntry = %s;", self::TABLE_NAME, $intidFormAnswer);
     $result = LoadDriver::query($sql);
     $coll = new BaseEntityCollection();
     while ($data = mysql_fetch_assoc($result)) {
         $tObj = new ContestFormAnswer();
         $tObj->materilize($data);
         $coll->addItem($tObj);
     }
     return $coll;
 }
 public static function LoadAll()
 {
     $sql = sprintf("SELECT * FROM %s;", self::TABLE_NAME);
     $result = LoadDriver::query($sql);
     $coll = new BaseEntityCollection();
     while ($data = mysql_fetch_assoc($result)) {
         $tObj = new Attachment();
         $tObj->materilize($data);
         $coll->addItem($tObj);
     }
     return $coll;
 }
 public static function LoadByFbuid($strFbuid)
 {
     $sql = sprintf("SELECT * FROM %s WHERE fbuid = %s %s;", self::TABLE_NAME, $strFbuid, $str);
     $result = LoadDriver::query($sql);
     $coll = new BaseEntityCollection();
     while ($data = mysql_fetch_assoc($result)) {
         $tObj = new ContestFormFieldType();
         $tObj->materilize($data);
         $coll->addItem($tObj);
     }
     return $coll;
 }
 public static function delete($table, $conditions)
 {
     $where = array();
     foreach ($conditions as $field => $val) {
         if (!is_numeric($val)) {
             $val = "'" . mysql_escape_string($val) . "'";
         }
         $where[] = $field . " = " . $val;
     }
     $sql = " DELETE FROM " . $table;
     $sql .= " WHERE ";
     $sql .= join('AND ', $where);
     $sql .= ";";
     $result = LoadDriver::query($sql);
     return $result;
 }
 public static function LoadAll($blnIncludeArchived = false)
 {
     if ($blnIncludeArchived === false) {
         $strExtra = ' WHERE delDate IS NULL';
     } elseif ($blnIncludeArchived === true) {
         $strExtra = ' WHERE delDate IS NOT NULL';
     } elseif (is_null($blnIncludeArchived)) {
         $strExtra = '';
     }
     $sql = sprintf("SELECT * FROM %s %s;", self::TABLE_NAME, $strExtra);
     $result = LoadDriver::query($sql);
     $coll = new BaseEntityCollection();
     while ($data = mysql_fetch_assoc($result)) {
         $tObj = new ContestEntry();
         $tObj->materilize($data);
         $coll->addItem($tObj);
     }
     return $coll;
 }
 public static function ExicuteOnDB($strExicute, $strDBName = 'DATABASE_1')
 {
     self::InitDB(constant($strDBName));
     return LoadDriver::Query($strExicute);
 }
 public function save()
 {
     foreach ($this->collection as $entity) {
         LoadDriver::save($entity);
     }
 }
 public static function getNextId($table, $pKey)
 {
     $sql = "SELECT MAX(" . $pKey . ") + 1 as 'id' FROM " . $table . " LIMIT 1;";
     $result = LoadDriver::query($sql);
     if ($result) {
         while ($row = mysql_fetch_assoc($result)) {
             $id = $row['id'];
             if (is_null($id)) {
                 return 1;
             } else {
                 return $id;
             }
         }
     }
 }