本文整理汇总了PHP中DataMapper::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP DataMapper::__construct方法的具体用法?PHP DataMapper::__construct怎么用?PHP DataMapper::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataMapper
的用法示例。
在下文中一共展示了DataMapper::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stdClass
function __construct($id = NULL)
{
// Set language
$this->help_lang();
if (!is_null($id) && ($comic = $this->get_cached($id))) {
parent::__construct();
$this->all[0] = new stdClass();
foreach ($comic->to_array() as $key => $c) {
$this->{$key} = $c;
// fill also the all array so result_count() is correctly 1
$this->all[0]->{$key} = $c;
}
if (isset($comic->licenses)) {
$this->licenses = $comic->licenses;
}
if (isset($comic->chapters)) {
$this->chapters = $comic->chapters;
}
return TRUE;
}
parent::__construct(NULL);
// We've overwrote the get() function so we need to look for $id from here
if (!empty($id) && is_numeric($id)) {
$this->where('id', $id)->get();
}
}
示例2:
function __construct($id = NULL)
{
parent::__construct(NULL);
if (!is_null($id)) {
$this->where('id', $id)->get();
}
}
示例3: array
function __construct($id = NULL)
{
parent::__construct($id);
$my_class = $this->my_class();
/* runtime relations configuration */
if (empty(self::$relations)) {
$this->config->load('relations', TRUE, TRUE);
}
if (!isset(self::$relations[$my_class])) {
self::$relations[$my_class] = array('has_many' => array(), 'has_one' => array());
}
$schema = $this->config->item($my_class, 'relations');
if ($schema) {
if (isset($schema['has_many'])) {
self::$relations[$my_class]['has_many'] = array_merge(self::$relations[$my_class]['has_many'], $schema['has_many']);
}
if (isset($schema['has_one'])) {
self::$relations[$my_class]['has_one'] = array_merge(self::$relations[$my_class]['has_one'], $schema['has_one']);
}
}
reset(self::$relations[$my_class]['has_many']);
foreach (self::$relations[$my_class]['has_many'] as $c => $rel) {
$this->has_many($c, $rel);
}
reset(self::$relations[$my_class]['has_one']);
foreach (self::$relations[$my_class]['has_one'] as $c => $rel) {
$this->has_one($c, $rel);
}
}
示例4: __construct
public function __construct(Database $db, $user)
{
parent::__construct($db);
$this->table('logins');
$this->columns(array('id', 'users_id', 'unixtime'));
$this->has_one = array($user);
}
示例5: Activity
function Activity($target = null)
{
parent::__construct();
if ($target) {
$this->target_class = get_class($target);
$this->target_id = $target->id;
}
}
示例6:
function __construct($id = NULL)
{
// Set the translations
$this->help_lang();
parent::__construct(NULL);
// We've overwrote some functions, and we need to use the get() from THIS model
if (!empty($id) && is_numeric($id)) {
$this->where('id', $id)->get();
}
}
示例7:
function __construct($id = NULL)
{
$this->CI =& get_instance();
/*
$classe = get_class($this) . '_link';
$link = new $classe;
$this->has_many = array_merge($this->has_many, $link->has_many);
*/
parent::__construct($id);
$this->getModuleStatus();
}
示例8: __construct
/**
* {@inheritdoc}
*/
public function __construct($id = null)
{
$trace = debug_backtrace();
if ((empty($trace[2]['object']) || !$trace[2]['object'] instanceof DataMapper) && self::$isInstantiated) {
throw new RuntimeException('System_setting can be instantiated only once!');
}
if ($this->hasTable($this->prefix . $this->table)) {
parent::__construct($id);
}
self::$isInstantiated = true;
}
示例9: IN
function __construct(\PDO $pdo)
{
parent::__construct($pdo);
// Запрос на выборку самых новых данных каждого типа
$this->selectLatestStmt = $this->pdo->prepare("SELECT *, DATE_FORMAT(`date`, '%d.%m.%Y') AS new_date FROM news WHERE date IN (SELECT MAX(date) FROM news GROUP BY type) ORDER BY type LIMIT 4");
$this->selectStmt = $this->pdo->prepare("SELECT *, DATE_FORMAT(`date`, '%d.%m.%Y в %H:%i') AS new_date FROM news WHERE id = ?");
$this->selectYearsStmt = $this->pdo->prepare("SELECT MAX(DATE_FORMAT(`date`, '%Y')) AS max, MIN(DATE_FORMAT(`date`, '%Y')) AS min FROM news");
$this->insertStmt = $this->pdo->prepare("INSERT INTO news (title, text, author, type, views, date, img) VALUES (?,?,?,?,?,?,?)");
$this->updateStmt = $this->pdo->prepare("UPDATE news SET title = ?, type = ?, text = ?, img = ? WHERE id = ?");
$this->deleteStmt = $this->pdo->prepare("DELETE FROM news WHERE id = ?");
}
示例10:
function __construct($id = NULL) {
// Set language
$this->help_lang();
parent::__construct(NULL);
// We've overwrote the get() function so we need to look for $id from here
if (!empty($id) && is_numeric($id)) {
$this->where('id', $id)->get();
}
}
示例11: __construct
public function __construct(Database $db, $user = null)
{
parent::__construct($db);
$this->table('blog');
$this->columns(array('id', 'title', 'content', 'unixtime'));
if (!empty($user) && $user instanceof User) {
$this->has_one = array($user);
} else {
$this->has_one = array(new User($db));
}
}
示例12: foreach
function __construct($id = NULL)
{
if (!is_null($id) && ($team = $this->get_cached($id))) {
parent::__construct();
foreach ($team->to_array() as $key => $t) {
$this->{$key} = $t;
// fill also the all array so result_count() is correctly 1
$this->all[0]->{$key} = $t;
}
return TRUE;
}
parent::__construct($id);
}
示例13: array
function __construct($id = NULL)
{
parent::__construct($id);
$my_class = $this->my_class();
/* runtime relations configuration */
if (empty(self::$relations)) {
$this->config->load('relations', TRUE, TRUE);
}
if (!isset(self::$relations[$my_class])) {
self::$relations[$my_class] = array('has_many' => array(), 'has_one' => array());
}
$schema = $this->config->item($my_class, 'relations');
if ($schema) {
if (isset($schema['has_many'])) {
self::$relations[$my_class]['has_many'] = array_merge(self::$relations[$my_class]['has_many'], $schema['has_many']);
}
if (isset($schema['has_one'])) {
self::$relations[$my_class]['has_one'] = array_merge(self::$relations[$my_class]['has_one'], $schema['has_one']);
}
}
reset(self::$relations[$my_class]['has_many']);
foreach (self::$relations[$my_class]['has_many'] as $c => $rel) {
$this->has_many($c, $rel);
}
reset(self::$relations[$my_class]['has_one']);
foreach (self::$relations[$my_class]['has_one'] as $c => $rel) {
$this->has_one($c, $rel);
}
/* fill in defaults */
if (!$id) {
if ($my_class == 'shift') {
$my_fields = $this->get_fields();
foreach ($my_fields as $mf) {
if (isset($mf['default'])) {
$this->{$mf['name']} = $mf['default'];
}
}
}
}
}
示例14: __construct
public function __construct($id = NULL, $abstract = FALSE)
{
// ci & mdi
if (!MDI_Model::$_ci) {
MDI_Model::$_ci =& get_instance();
}
if (!MDI_Model::$_mdi) {
MDI_Model::$_mdi =& MDI_Model::$_ci->mdi;
}
// abstract check
$is_abstract = $abstract ? TRUE : $this->abstract;
// abstract
if ($this->abstract == FALSE) {
if (empty($this->table)) {
mdi::error("MDI_Model::__construct Error - table did not defined(model:" . get_class($this) . ")");
}
}
// load syncher
if ($this->syncher == NULL) {
MDI_Model::$_ci->mdi->load('features/dbsyncher');
$this->syncher = new DBSyncher();
}
//build validation
$this->build_validation();
// construct
if (!$is_abstract) {
$is_sync = FALSE;
if (MDI_Model::$_ci->mdi->config('auto_db_sync')) {
$is_sync = $this->syncher->sync($this);
}
parent::__construct($id);
$this->initialize();
if ($is_sync) {
$this->post_sync();
}
}
}
示例15:
function __construct()
{
parent::__construct();
//$this->load->helper('security');
}