當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseObject類代碼示例

本文整理匯總了PHP中DatabaseObject的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseObject類的具體用法?PHP DatabaseObject怎麽用?PHP DatabaseObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DatabaseObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setDatabaseObject

 public function setDatabaseObject(DatabaseObject $object)
 {
     $this->_dbObject = $object;
     $this->_db = $object->getDb();
     $this->_table = $object->getTable();
     return $this;
 }
開發者ID:sandin,項目名稱:iMemo,代碼行數:7,代碼來源:DoubleDatabase.php

示例2: populate

 /**
  * 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;
         }
     }
 }
開發者ID:jcorbinredtree,項目名稱:framework,代碼行數:59,代碼來源:FrameworkTestCase.php

示例3: joinObject

 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);
 }
開發者ID:jcorbinredtree,項目名稱:framework,代碼行數:15,代碼來源:QueryBuilder.php

示例4: handleData

 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     if (!$this->serverID) {
         $this->data['serverID'] = 0;
     }
 }
開發者ID:Evil-Co-Legacy,項目名稱:Bash-Database,代碼行數:10,代碼來源:Server.class.php

示例5: handleData

 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     if (!$this->moduleID) {
         $this->data['moduleID'] = 0;
     }
 }
開發者ID:Evil-Co-Legacy,項目名稱:Evil-Co.de-CMS,代碼行數:10,代碼來源:DynamicPageModuleTemplate.class.php

示例6: handleData

 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     if (!$this->entryID) {
         $this->data['entryID'] = 0;
     }
 }
開發者ID:Evil-Co-Legacy,項目名稱:Bash-Database,代碼行數:10,代碼來源:BashEntry.class.php

示例7: create

 /**
  * 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));
 }
開發者ID:sourcefabric,項目名稱:newscoop,代碼行數:16,代碼來源:Translation.php

示例8: __construct

 public function __construct()
 {
     // This is required or this constructor will override the
     // database object
     parent::__construct();
     $this->plans = new CustomerPlan();
 }
開發者ID:carriercomm,項目名稱:Sipen-CMS,代碼行數:7,代碼來源:customer.class.php

示例9: __construct

 public function __construct($db)
 {
     parent::__construct($db, 'lds0019_notes_order', 'order_id');
     $this->add('note_id');
     $this->add('fronthand');
     $this->add('backhand');
 }
開發者ID:sandin,項目名稱:iMemo,代碼行數:7,代碼來源:NotesOrder.php

示例10: getInstance

 public static function getInstance()
 {
     if (!self::$m_instance) {
         self::$m_instance = new self();
     }
     return self::$m_instance;
 }
開發者ID:troycaeser,項目名稱:WheresMyWallet,代碼行數:7,代碼來源:database.php

示例11: __construct

 /**
  * 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);
 }
開發者ID:CaribeSoy,項目名稱:contest-wcf,代碼行數:13,代碼來源:ContestCouponParticipant.class.php

示例12: delete

    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
開發者ID:nistormihai,項目名稱:Newscoop,代碼行數:27,代碼來源:Attachment.php

示例13: fetch

	/**
	 * 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;
    }
開發者ID:nistormihai,項目名稱:Newscoop,代碼行數:38,代碼來源:GeoLocation.php

示例14: delete

 public function delete()
 {
     $deleted = parent::delete();
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }
開發者ID:nidzix,項目名稱:Newscoop,代碼行數:7,代碼來源:Soundcloud.php

示例15: __construct

 public function __construct()
 {
     // This is required or this constructor will override the
     // database object
     parent::__construct();
     $this->loadSettings();
 }
開發者ID:carriercomm,項目名稱:Sipen-CMS,代碼行數:7,代碼來源:setting.class.php


注:本文中的DatabaseObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。