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


PHP Variable::factory方法代碼示例

本文整理匯總了PHP中Variable::factory方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::factory方法的具體用法?PHP Variable::factory怎麽用?PHP Variable::factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Variable的用法示例。


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

示例1: __construct

 /**
  * Construction of object initializes a connection resource to the link
  * variable
  * @param string $dsn
  */
 public function __construct($database_type, $username, $password = null, $database_name = null, $host = null, $port = null)
 {
     $this->database_type = \Variable::factory('string', $database_type, 'database_type');
     $this->database_type->setLimit(12);
     $this->database_type->setLabel(t('Database type'));
     $this->database_type->wordCharactersOnly();
     $this->database_name = \Variable::factory('string', $database_name, 'database_name');
     $this->database_name->setLimit(58);
     $this->database_name->setLabel(t('Database name'));
     $this->database_name->wordCharactersOnly();
     $this->username = \Variable::factory('string', $username, 'username');
     $this->username->setLimit(255);
     $this->username->setLabel(t('Database user name'));
     $this->username->wordCharactersOnly();
     $this->password = \Variable::factory('string', $password, 'password');
     $this->password->setLimit(255);
     $this->password->setLabel(t('Database password'));
     $this->password->setInputType('password');
     $this->table_prefix = \Variable::factory('string', null, 'table_prefix');
     $this->table_prefix->allowNull(true);
     $this->table_prefix->setLimit(5);
     $this->table_prefix->setLabel(t('Table prefix'));
     $this->table_prefix->wordCharactersOnly();
     $this->host = \Variable::factory('string', null, 'host');
     $this->host->setLimit(255);
     $this->host->setLabel('Database host');
     $this->host->allowNull(true);
     $this->host->set($host);
     $this->port = \Variable::factory('integer', null, 'port');
     $this->port->setLabel('Database port');
     $this->port->setRange('1', '65535');
     $this->port->allowNull(true);
     if (!empty($port)) {
         $this->port->set($port);
     }
 }
開發者ID:par-orillonsoft,項目名稱:phpwebsite,代碼行數:41,代碼來源:DSN.php

示例2: setName

 public function setName($name)
 {
     $this->name = \Variable::factory('alphanumeric', $name);
 }
開發者ID:HaldunA,項目名稱:phpwebsite,代碼行數:4,代碼來源:Datatype.php


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