Example #1
0
 public function MakeHistoryEntry($Command, $Array = false, $delete = false)
 {
     if (isset(DB_DataObject2::$INI[$this->_database][$this->__table . '_History'])) {
         $History = RD::$Self->DB($this->_database, $this->__table . '_History');
         if (!$Array) {
             $Array = $this->toArray();
         }
         $ID = $Array['ID'];
         unset($Array['ID']);
         $History->setFrom($Array);
         $History->History_Reference_ID = $ID;
         $History->History_Timestamp = DB_DataObject2_Cast::sql('UNIX_TIMESTAMP()');
         if ($delete) {
             $History->History_Deleted = 1;
         }
         $History_ID = $History->insert();
         if (isset(DB_DataObject2::$INI[$this->_database]['HistoryTracking'])) {
             $HistoryTracking = RD::$Self->DB($this->_database, 'HistoryTracking');
             $Name = '';
             if (RD::$Self->GetUser()) {
                 $HistoryTracking->User_ID = RD::$Self->GetUser('ID');
                 $Name .= 'User ' . RD::$Self->GetUser('Name') . ' does a ';
             }
             $Name .= $Command . ' on table ' . $this->__table . ' with entry #' . $ID;
             $HistoryTracking->Name = $Name;
             $HistoryTracking->Table = $this->__table;
             $HistoryTracking->Table_ID = $ID;
             $HistoryTracking->Table_History_ID = $History_ID;
             $HistoryTracking->Query = $this->last_query;
             $HistoryTracking->insert();
         }
     }
 }
Example #2
0
 /**
  * DateTime Constructor
  *
  * create a Cast object from a Date/Time
  * Maybe should accept a Date object.!
  * NO VALIDATION DONE, although some crappy re-calcing done!
  * 
  * @param   vargs... accepts
  *              noargs (now)
  *              yyyy-mm-dd HH:MM:SS (Iso)
  *              array(yyyy,mm,dd,HH,MM,SS) 
  *
  *
  * @return   object DB_DataObject2_Cast
  * @access   public 
  * @author   therion 5 at hotmail
  */
 public static function dateTime()
 {
     $args = func_get_args();
     switch (count($args)) {
         case 0:
             // no args = now!
             $datetime = date('Y-m-d G:i:s', mktime());
         case 1:
             // continue on from 0 args.
             if (!isset($datetime)) {
                 $datetime = $args[0];
             }
             $parts = explode(' ', $datetime);
             $bits = explode('-', $parts[0]);
             $bits = array_merge($bits, explode(':', $parts[1]));
             break;
         default:
             // 2 or more..
             $bits = $args;
     }
     if (count($bits) != 6) {
         // PEAR ERROR?
         return false;
     }
     $r = DB_DataObject2_Cast::date($bits[0], $bits[1], $bits[2]);
     if (!$r) {
         return $r;
         // pass thru error (False) - doesnt happen at present!
     }
     // change the type!
     $r->type = 'datetime';
     // should we mathematically sort this out..
     // (or just assume that no-one's dumb enough to enter 26:90:90 as a time!
     $r->hour = $bits[3];
     $r->minute = $bits[4];
     $r->second = $bits[5];
     return $r;
 }