示例#1
0
 public function setDatabaseObject(DatabaseObject $object)
 {
     $this->_dbObject = $object;
     $this->_db = $object->getDb();
     $this->_table = $object->getTable();
     return $this;
 }
 /**
  * Populates the given DatabaseObject with dummy data
  *
  * @param DatabaseObject $obj
  * @return void
  */
 protected function populate(DatabaseObject &$obj)
 {
     $meta = $obj->meta();
     $key = $meta->getKey();
     $fields = $meta->getColumnMap();
     foreach ($fields as $property => $field) {
         if ($field == $key && isset($obj->{$property})) {
             continue;
         }
         $def = $meta->getColumnDefinition($field);
         $type = strtolower(Params::generic($def, 'native_type'));
         switch ($type) {
             case 'int':
             case 'integer':
             case 'float':
             case 'currency':
             case 'decimal':
             case 'double':
             case 'real':
             case 'tinyint':
             case 'short':
             case 'long':
                 $obj->{$property} = mt_rand(0, 100);
                 break;
             case 'date':
             case 'datetime':
             case 'timestamp':
                 // Fuzz two weeks around now
                 $window = 1209600;
                 // 14 days * 24 hours * 60 minutes * 60 seconds
                 $time = time() - $window / 2 + mt_rand(0, $window);
                 if ($type == 'date') {
                     $lt = localtime($time, true);
                     $time = mktime(0, 0, 0, $lt['tm_mday'], $lt['tm_mon'] + 1, $lt['tm_year'] + 1900);
                     $lt = null;
                 }
                 $obj->{$property} = $time;
                 break;
             case 'time':
                 // range is +- 838:59:59, but since this populate thing
                 // isn't really all it could be anyhow, let's just do
                 // positive values
                 $obj->{$property} = mt_rand(1, 839 * 60 * 60 - 1);
                 break;
             case 'var_string':
                 $obj->{$property} = 'dummy string content ' . uniqid();
                 break;
             default:
                 $obj->{$property} = uniqid();
                 break;
         }
     }
 }
示例#3
0
 public function joinObject(DatabaseObject $dboA, DatabaseObject $dboB, $keyA = null, $keyB = null)
 {
     $metaA = $dboA->meta();
     $metaB = $dboB->meta();
     $tableA = $metaA->getTable();
     $tableB = $metaB->getTable();
     if (!$keyA) {
         $keyA = $metaA->getKey();
     }
     if (!$keyB) {
         $keyB = $keyA;
     }
     $sql = "INNER JOIN `{$tableB}` ON `{$tableB}`.`{$keyB}` = `{$tableA}`.`{$keyA}`";
     array_push($this->joins, $sql);
 }
示例#4
0
 /**
  * Create a translation of a phrase.  If the phrase ID is set in the
  * constructor, we assume that the phrase already exists and we are
  * just creating a translation, and not a new phrase.
  *
  * @param string $p_text
  * 		Optional. The translation text.
  * @return boolean
  */
 public function create($p_text = null)
 {
     if (!isset($this->m_data['phrase_id'])) {
         $this->m_data['phrase_id'] = Translation::__GeneratePhraseId();
     }
     return parent::create(array("translation_text" => $p_text));
 }
示例#5
0
 public function __construct()
 {
     // This is required or this constructor will override the
     // database object
     parent::__construct();
     $this->plans = new CustomerPlan();
 }
 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     if (!$this->serverID) {
         $this->data['serverID'] = 0;
     }
 }
 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     if (!$this->moduleID) {
         $this->data['moduleID'] = 0;
     }
 }
示例#8
0
 public function __construct($db)
 {
     parent::__construct($db, 'lds0019_notes_order', 'order_id');
     $this->add('note_id');
     $this->add('fronthand');
     $this->add('backhand');
 }
示例#9
0
 public static function getInstance()
 {
     if (!self::$m_instance) {
         self::$m_instance = new self();
     }
     return self::$m_instance;
 }
 /**
  * Creates a new object.
  *
  * @param	integer		$id
  * @param 	array<mixed>	$row
  */
 public function __construct($id, $row = null)
 {
     if ($id !== null) {
         throw new SystemException('not implemented');
     }
     parent::__construct($row);
 }
示例#11
0
    public function delete()
    {
        if (!$this->exists()) {
            return false;
        }
        // Deleting the from from disk path is the most common place for
        // something to go wrong, so we do that first.
        $file = $this->getStorageLocation();
        if (file_exists($file) && is_file($file)) {
            unlink($file);
        }

        // Delete all the references to this image.
        ArticleAttachment::OnAttachmentDelete($this->m_data['id']);

        // Delete the description
        Translation::deletePhrase($this->m_data['fk_description_id']);

        $tmpData = $this->m_data;

        // Delete the record in the database
        $success = parent::delete();

        $logtext = getGS('File #$1 "$2" deleted.', $tmpData['id'], $tmpData['file_name']);
        Log::Message($logtext, null, 39);
        return $success;
    } // fn delete
示例#12
0
	/**
	 * Fetch a single record from the database for the given key.
	 *
	 * @param array $p_arg
	 *		If the record has already been fetched and we just need to
	 * 		assign the data to the object's internal member variable.
	 *
	 * @return boolean
	 *		TRUE on success, FALSE on failure
	 */
    public function fetch($arg = null)
    {
    	global $g_ado_db;

        if (is_array($arg)) {
        	return parent::fetch($arg);
        }

        if (!$this->keyValuesExist()) {
        	return false;
        }
        if ($this->readFromCache() !== false) {
        	return true;
        }

        $queryStr = 'SELECT *, X(poi_location) as latitude, Y(poi_location) as longitude
                FROM ' . self::TABLE . '
                WHERE id = ' . $this->getId();
        $this->m_data = $g_ado_db->GetRow($queryStr);
        $this->m_exists = count($this->m_data) > 0;

        if ($this->m_exists) {
		    // Write the object to cache
		    $this->writeCache();
		}

        return $this->m_exists;
    }
示例#13
0
 public function delete()
 {
     $deleted = parent::delete();
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }
示例#14
0
 public function __construct()
 {
     // This is required or this constructor will override the
     // database object
     parent::__construct();
     $this->loadSettings();
 }
 public function __construct()
 {
     // This is required or this constructor will override the
     // database object
     parent::__construct();
     $this->orderby = "planid";
 }
 public function __construct($db, $table)
 {
     parent::__construct($db, $table, 'id');
     $this->add('name_of_set');
     $this->add('uploader_id');
     $this->add('ts_created', time(), self::TYPE_TIMESTAMP);
 }
示例#17
0
 public function __construct(array $row)
 {
     $this->_Params = array('id' => 'ID', 'item_id' => 'ItemID', 'hash' => 'Hash', 'name' => 'Name', 'price' => 'PriceAll', 'price_one' => 'Price', 'amount' => 'Amount', 'refine' => 'Refine', 'slot0' => 'Slot0', 'slot1' => 'Slot1', 'slot2' => 'Slot2', 'slot3' => 'Slot3', 'avg_all' => 'AvgAll', 'name_url' => 'NameUrl', 'vender_id' => 'VenderID', 'description_en' => 'DescriptionEN', 'description_fr' => 'DescriptionFR');
     parent::__construct($row);
     $this->NameUrl = self::cleanName($this->Name);
     $this->Vender = new RoVender(Framework::getDb()->getFirstRow("SELECT * FROM bot_vender WHERE char_id = '" . esc($this->VenderID) . "'"));
 }
示例#18
0
 public function __construct($db)
 {
     parent::__construct($db, 'lds0019_notes_tags', 'tag_id');
     $this->add('tag_name');
     $this->add('user_id');
     $this->add('ts_created', time());
 }
示例#19
0
 public function __construct($db)
 {
     parent::__construct($db, 'lds0019_notes_content', 'content_id');
     $this->add('note_id');
     $this->add('content', null);
     $this->add('ts_modified', time());
 }
 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     if (!$this->entryID) {
         $this->data['entryID'] = 0;
     }
 }
 public static function create($registrationID)
 {
     global $core;
     $assocArr = array("registrationID" => $registrationID);
     $rObj = parent::makeNew("deviceRegistration", "entryID", $assocArr, "DeviceRegistration");
     return $rObj;
 }
示例#22
0
 /**
  * Creates a new Spec object.
  * 
  * @param	spec id
  */
 public function __construct($specID, $row = null)
 {
     if ($row === null) {
         $row = self::$cache['bySpecID'][$specID];
     }
     parent::__construct($row);
 }
示例#23
0
 /**
  * Constructor
  * @access   public
  */
 function EvaluationObjectDB()
 {
     /* Set default values -------------------------------------------------- */
     parent::DatabaseObject();
     $this->instanceof = INSTANCEOF_EVALDBOBJECT;
     /* --------------------------------------------------------------------- */
 }
示例#24
0
 /**
  * Creates a new NavalFormation object.
  * 
  * @param	int		nf id
  * @param	array	db row
  */
 public function __construct($navalFormationID, $row = null)
 {
     if ($row === null) {
         $sql = "SELECT ugml_naval_formation.*,\r\n\t\t    \t\t\tGROUP_CONCAT(\r\n\t\t    \t\t\t\tCONCAT(ugml_naval_formation_to_users.userID, ',', ugml_naval_formation_to_users.joinTime)\r\n\t\t    \t\t\t\tSEPARATOR ';')\r\n\t\t    \t\t\tAS users,\r\n\t\t    \t\t\tGROUP_CONCAT(\r\n\t\t    \t\t\t\tCONCAT(ugml_fleet.ownerID, ',', ugml_fleet.fleetID)\r\n\t\t    \t\t\t\tSEPARATOR ';')\r\n\t\t    \t\t\tAS fleets\r\n\t\t\t\t\tFROM ugml_naval_formation\r\n\t\t\t\t\tLEFT JOIN ugml_naval_formation_to_users\r\n\t\t\t\t\t\tON ugml_naval_formation.formationID = ugml_naval_formation_to_users.formationID\r\n\t\t\t\t\tLEFT JOIN ugml_fleet\r\n\t\t\t\t\t\tON ugml_naval_formation.formationID = ugml_fleet.formationID\r\n\t\t\t\t\tWHERE ugml_naval_formation.formationID = " . $navalFormationID . "\r\n\t\t\t\t\tGROUP BY ugml_naval_formation.formationID";
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
     // create users array
     $parts = explode(';', $this->data['users']);
     foreach ($parts as $part) {
         if (strlen($part) > 2) {
             list($userID, $joinTime) = explode(',', $part);
             if (!isset($this->users[$userID])) {
                 $this->users[$userID] = new LWUser($userID);
                 $this->users[$userID]->joinTime = $joinTime;
             }
         }
     }
     // create fleets array
     $parts = explode(';', $this->data['fleets']);
     foreach ($parts as $part) {
         if (strlen($part) > 2) {
             list($userID, $fleetID) = explode(',', $part);
             $this->fleets[$fleetID] = Fleet::getInstance($fleetID);
         }
     }
 }
示例#25
0
	function form ($form) {
		$db =& DB::get();

		$purchasetable = DatabaseObject::tablename(Purchase::$table);
		$next = $db->query("SELECT auto_increment as id FROM information_schema.tables WHERE table_schema=database() AND table_name='$purchasetable' LIMIT 1");

		$Order = $this->Order;
		$Order->_2COcart_order_id = date('mdy').'-'.date('His').'-'.$next->id;

		// Build the transaction
		$_ = array();

		// Required
		$_['sid']				= $this->settings['sid'];
		$_['total']				= number_format($Order->Cart->Totals->total,$this->precision);
		$_['cart_order_id']		= $Order->_2COcart_order_id;
		$_['vendor_order_id']	= $this->session;
		$_['id_type']			= 1;

		// Extras
		if ($this->settings['testmode'] == "on")
			$_['demo']			= "Y";

		$_['fixed'] 			= "Y";
		$_['skip_landing'] 		= "1";

		$_['x_Receipt_Link_URL'] = $this->settings['returnurl'];

		// Line Items
		foreach($this->Order->Cart->contents as $i => $Item) {
			// $description[] = $Item->quantity."x ".$Item->name.((!empty($Item->optionlabel))?' '.$Item->optionlabel:'');
			$id = $i+1;
			$_['c_prod_'.$id]			= 'ecart_pid-'.$Item->product.','.$Item->quantity;
			$_['c_name_'.$id]			= $Item->name;
			$_['c_description_'.$id]	= !empty($Item->option->label)?$Item->$Item->option->label:'';
			$_['c_price_'.$id]			= number_format($Item->unitprice,$this->precision);

		}

		$_['card_holder_name'] 		= $Order->Customer->firstname.' '.$Order->Customer->lastname;
		$_['street_address'] 		= $Order->Billing->address;
		$_['street_address2'] 		= $Order->Billing->xaddress;
		$_['city'] 					= $Order->Billing->city;
		$_['state'] 				= $Order->Billing->state;
		$_['zip'] 					= $Order->Billing->postcode;
		$_['country'] 				= $Order->Billing->country;
		$_['email'] 				= $Order->Customer->email;
		$_['phone'] 				= $Order->Customer->phone;

		$_['ship_name'] 			= $Order->Customer->firstname.' '.$Order->Customer->lastname;
		$_['ship_street_address'] 	= $Order->Shipping->address;
		$_['ship_street_address2'] 	= $Order->Shipping->xaddress;
		$_['ship_city'] 			= $Order->Shipping->city;
		$_['ship_state'] 			= $Order->Shipping->state;
		$_['ship_zip'] 				= $Order->Shipping->postcode;
		$_['ship_country'] 			= $Order->Shipping->country;

		return $form.$this->format($_);
	}
 /**
  * Creates a new Attachment object.
  *
  * @param	integer		$attachmentID
  * @param	array<mixed>	$row
  */
 public function __construct($attachmentID, $row = null)
 {
     if ($attachmentID !== null) {
         $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_attachment\n\t\t\t\tWHERE\tattachmentID = " . $attachmentID;
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
 }
 /**
  * Creates a Loggable object.
  * 
  * @param	integer	$loggableID
  * @param	array	$row
  */
 public function __construct($loggableID, $row = null)
 {
     if ($loggableID !== null) {
         $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_actionlog_loggable\n\t\t\t\tWHERE\tloggableID = " . intval($loggableID);
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
 }
示例#28
0
 /**
  * This table delays an issue's publish time to a later date.
  *
  * @param int $p_id
  */
 public function IssuePublish($p_id = null)
 {
     parent::DatabaseObject($this->m_columnNames);
     $this->m_data['id'] = $p_id;
     if ($this->keyValuesExist()) {
         $this->fetch();
     }
 }
 /**
  * Creates a new Warning object.
  *
  * @param	integer		$warningID
  * @param	array<mixed>	$row
  */
 public function __construct($warningID, $row = null)
 {
     if ($warningID !== null) {
         $sql = "SELECT\twarning.*,\n\t\t\t\t\t(SELECT COUNT(*) FROM wcf" . WCF_N . "_user_infraction_warning_to_user WHERE warningID = warning.warningID) AS warnings\n\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_warning warning\n\t\t\t\tWHERE\twarning.warningID = " . $warningID;
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
 }
 /**
  * Creates a new SessionAccessLog object.
  *
  * @param	integer		$sessionAccessLogID
  * @param	array<mixed>	$row
  */
 public function __construct($sessionAccessLogID, $row = null)
 {
     if ($sessionAccessLogID !== null) {
         $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_access_log\n\t\t\t\tWHERE\tsessionAccessLogID = " . $sessionAccessLogID;
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
 }