本文整理汇总了PHP中DB::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::__construct方法的具体用法?PHP DB::__construct怎么用?PHP DB::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($vars = null)
{
parent::__construct();
$this->scrubber = new Scrubber();
$this->template = new Template();
$this->cleaned = $this->scrubber->fromHtml($vars);
}
示例2: __construct
public function __construct($vars = null)
{
parent::__construct();
#$this->template = new Template;
$this->post = $vars;
$this->scrubber = new Scrubber();
}
示例3: __construct
public function __construct($table = null)
{
parent::__construct();
if ($table != null) {
$this->table($table);
}
return $this;
}
示例4: __construct
public function __construct(array $options = [])
{
$defaults = [];
$options += $defaults;
parent::__construct($options);
$this->tableMain = 'predb';
$this->tableTemp = 'predb_imports';
}
示例5:
function __construct()
{
parent::__construct();
$this->receiveMessage();
$this->loadData();
$this->showALLMessages();
$this->showForm();
}
示例6: __construct
public function __construct($vars = null)
{
parent::__construct();
$this->scrubber = new Scrubber();
if (!is_null($vars)) {
$this->cleaned = $this->scrubber->fromHtml($vars);
}
}
示例7: __construct
public function __construct()
{
//调用父类构造方法
parent::__construct();
//1. 注册
session_set_save_handler(array($this, 'sess_open'), array($this, 'sess_close'), array($this, 'sess_read'), array($this, 'sess_write'), array($this, 'sess_destroy'), array($this, 'sess_gc'));
//2. 开启session
@session_start();
}
示例8: __construct
/**
* __construct function.
*
* @access public
* @param mixed $host (default: null)
* @param mixed $port (default: null)
* @param mixed $dbname (default: null)
* @param mixed $username (default: null)
* @param mixed $password (default: null)
* @param mixed $charset (default: null)
* @return void
*/
public function __construct($username = null, $password = null)
{
# set parameters
$this->set_db_params();
# rewrite user/pass if requested - for installation
$username == null ?: ($this->username = $username);
$password == null ?: ($this->password = $password);
# construct
parent::__construct($this->username, $this->password, $this->charset);
}
示例9: __construct
public function __construct($host, $user, $password, $dbname , $connect = false,
$charset = 'utf8') {
parent::__construct($host, $user, $password, $dbname , $connect = false,
$charset = 'utf8');
$this->logDir = SuiShiPHPConfig::getSqlLogDir();
$this->logSql = SuiShiPHPConfig::get('ENABLE_SQL_LOG');
//初始化log file
$this->iniLogConfig();
}
示例10: __construct
public function __construct()
{
parent::__construct();
if (!session_start()) {
if (!$this->admin->status() && !preg_match("/^login.*\$/i", $action)) {
header('Location: ' . BASE_PATH . 'error/session_error/');
exit;
}
}
}
示例11:
function __construct($id = 0)
{
parent::__construct();
if ($id) {
$this->id = $id;
$r = $this->getOne($id);
$this->userid = $r->userid;
$this->tenderid = $r->tenderid;
$this->score = $r->score;
}
}
示例12: __construct
public function __construct($str)
{
global $first;
parent::__construct();
$this->filter = "*";
$this->where = "1";
$this->limit = "0 , 10";
$this->condition = " ";
$this->order = "date desc";
$this->table = $first . $str;
}
示例13: __construct
/**
* Constructor. When a instance of the class is loaded it will
* attempt to find the primary key of the table we are dealing with.
* If a value is passed to the constructor it will be looked up in
* the table against the primary key and if a row is found it will
* be assigned into the object.
*
* @access public
* @param mixed $id Id to lookup against primary key field
* @return void
*/
public function __construct($id = null)
{
parent::__construct();
if (!is_array($_ENV['describeTable'])) {
$_ENV['describeTable'] = array();
}
# Make sure we have a table to look at
if (is_null($this->_table)) {
throw new Exception('No table defined for access in model');
}
# Verify Model is not being use directly, and setup _fetchClass
$class = get_class($this);
if ($class == 'Model') {
throw new Exception('Model should not be used directly');
}
$this->_fetchClass = $class;
# Check to see if we've already checked table layout this request
if (array_key_exists($this->_table, $_ENV['describeTable'])) {
$this->_key = $_ENV['describeTable'][$this->_table]['key'];
$this->_metadata = $_ENV['describeTable'][$this->_table]['metadata'];
} else {
# Begin process of retrieving table layout
$sql = "DESCRIBE " . $this->_table;
$rows = $this->query($sql);
# If we got back our rows then parse out the data
if (is_array($rows)) {
foreach ($rows as $row) {
# Format of Type field is "datatype(length) attributes" ex. int(11) unsigned
preg_match('/^([a-z]+)\\(([0-9]+)\\)(.*)/i', $row->Type, $matches);
$this->_metadata[$row->Field] = new stdClass();
if (count($matches) > 0) {
$this->_metadata[$row->Field]->type = trim($matches[1]);
$this->_metadata[$row->Field]->length = trim($matches[2]);
$this->_metadata[$row->Field]->attr = trim($matches[3]);
$this->_metadata[$row->Field]->extra = trim($row->Extra);
} else {
$this->_metadata[$row->Field]->type = $row->Type;
}
# Check to see if the field we're dealing with is a primary key
if (preg_match('/\\bPRI\\b/', $row->Key)) {
$this->_key = $row->Field;
$this->_metadata[$row->Field]->primary = true;
}
}
}
$_ENV['describeTable'][$this->_table] = array('key' => $this->_key, 'metadata' => $this->_metadata);
}
# If we know the primary key and have an id, fetch the row
if (!empty($this->_key) and !is_null($id)) {
$row = $this->get($id);
}
}
示例14: __construct
public function __construct(){
parent::__construct();
session_set_save_handler(
array($this,'sess_open'),
array($this,'sess_close'),
array($this,'sess_read'),
array($this,'sess_write'),
array($this,'sess_destroy'),
array($this,'sess_gc')
);
@session_start();
}
示例15: __construct
public function __construct(DBConnect $dbConnect)
{
$this->dbConnect = $dbConnect;
try {
parent::__construct('mysql:host=' . $dbConnect->getHost() . ';dbname=' . $dbConnect->getDatabase() . ($dbConnect->getCharset() !== null ? ';charset=' . $dbConnect->getCharset() : null), $dbConnect->getUsername(), $dbConnect->getPassword());
$this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
if (($charset = $dbConnect->getCharset()) !== null) {
$this->query("SET NAMES '" . $charset . "'");
$this->query("SET CHARSET '" . $charset . "'");
}
$this->triggerListeners('onConnect', array($this, $this->dbConnect));
} catch (\PDOException $e) {
throw new DBException($e);
}
}