Пример #1
0
 function ClearForEvent($event_id)
 {
     if ($event_id) {
         $query = "DELETE FROM recurrence WHERE event_id = {$event_id}";
         MyActiveRecord::Query($query);
     }
 }
Пример #2
0
 function delete()
 {
     foreach ($this->get_photos() as $photo) {
         $photo->delete(true);
     }
     return MyActiveRecord::Query("DELETE FROM galleries WHERE id = {$this->id}");
 }
Пример #3
0
 function delete()
 {
     $target_path = SERVER_DOCUMENTS_ROOT . $this->filename;
     if (file_exists($target_path)) {
         unlink($target_path);
     }
     return MyActiveRecord::Query("DELETE FROM documents WHERE id ={$this->id}");
 }
Пример #4
0
 function delete()
 {
     $target_path = $this->get_local_image_path($this->filename);
     if (file_exists($target_path)) {
         unlink($target_path);
     }
     return MyActiveRecord::Query("DELETE FROM photos WHERE id ={$this->id}");
 }
 /**
  * Deletes the object from the database
  * eg:
  * <code>
  * $car = MyActiveRecord::FindById('Car', 1);
  * $car->destroy();
  * </code>
  *
  * @return  boolean True on success, False on failure
  */
 public function destroy()
 {
     $table = MyActiveRecord::Class2Table($this);
     return MyActiveRecord::Query("DELETE FROM `{$table}` WHERE `{$table}`.`id`={$this->id}");
 }
Пример #6
0
 /**
  * Count number of items of type strClass which are linked to the current object.
  *
  * @param string $strClass Class of objects to count.
  * @param string $mxdCondition Additional WHERE clause
  * @return int
  */
 function count_linked($strClass, $mxdCondition = null)
 {
     if (isset($this->id) && $this->id > 0) {
         $this->id = intval($this->id);
         // only attempt to find links if this object has an id
         $table = MyActiveRecord::Class2Table($strClass);
         $thistable = MyActiveRecord::Class2Table($this);
         $linktable = MyActiveRecord::GetLinkTable($table, $thistable);
         $sql = "SELECT COUNT(1) AS _count FROM {$table} INNER JOIN {$linktable} ON {$table}_id = {$table}.id WHERE {$linktable}.{$thistable}_id = {$this->id} ";
         if (is_array($mxdCondition)) {
             foreach ($mxdCondition as $key => $val) {
                 $val = addslashes($val);
                 $sql .= " AND {$key} = '{$val}' ";
             }
         } else {
             if ($mxdCondition) {
                 $sql .= " AND {$mxdCondition}";
             }
         }
         $result = MyActiveRecord::Query($sql);
         if ($row = mysql_fetch_object($result)) {
             return $row->_count;
         }
     }
     return 0;
 }
Пример #7
0
 /**
  * Deletes the object from the database
  * eg:
  * <code>
  * $car = MyActiveRecord::FindById('Car', 1);
  * $car->destroy();
  * </code>
  *
  * @return	boolean	True on success, False on failure
  */
 function destroy()
 {
     $table = MyActiveRecord::Class2Table($this);
     return MyActiveRecord::Query("DELETE FROM {$table} WHERE id ={$this->id}");
 }