当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectModel::fieldsRequiredDatabase方法代码示例

本文整理汇总了PHP中ObjectModel::fieldsRequiredDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectModel::fieldsRequiredDatabase方法的具体用法?PHP ObjectModel::fieldsRequiredDatabase怎么用?PHP ObjectModel::fieldsRequiredDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectModel的用法示例。


在下文中一共展示了ObjectModel::fieldsRequiredDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

    /**
     * Build object
     *
     * @param integer $id Existing object id in order to load object (optional)
     * @param integer $id_lang Required if object is multilingual (optional)
     */
    public function __construct($id = NULL, $id_lang = NULL)
    {
        if ($id_lang != NULL && Validate::isLoadedObject(new Language($id_lang))) {
            $this->id_lang = $id_lang;
        } elseif ($id_lang != NULL) {
            $this->id_lang = Configuration::get('PS_LANG_DEFAULT');
        }
        /* Connect to database and check SQL table/identifier */
        if (!Validate::isTableOrIdentifier($this->identifier) or !Validate::isTableOrIdentifier($this->table)) {
            die(Tools::displayError());
        }
        $this->identifier = pSQL($this->identifier);
        /* Load object from database if object id is present */
        if ($id) {
            if (!isset(self::$_cache[$this->table][(int) $id][(int) $id_lang])) {
                self::$_cache[$this->table][(int) $id][(int) $id_lang] = Db::getInstance()->getRow('
				SELECT *
				FROM `' . _DB_PREFIX_ . $this->table . '` a ' . ($id_lang ? 'LEFT JOIN `' . pSQL(_DB_PREFIX_ . $this->table) . '_lang` b ON (a.`' . $this->identifier . '` = b.`' . $this->identifier . '` AND `id_lang` = ' . (int) $id_lang . ')' : '') . ' WHERE a.`' . $this->identifier . '` = ' . (int) $id);
            }
            $result = self::$_cache[$this->table][(int) $id][(int) $id_lang];
            if ($result) {
                $this->id = (int) $id;
                foreach ($result as $key => $value) {
                    if (key_exists($key, $this)) {
                        $this->{$key} = $value;
                    }
                }
                /* Join multilingual tables */
                if (!$id_lang and method_exists($this, 'getTranslationsFieldsChild')) {
                    $result = Db::getInstance()->ExecuteS('
					SELECT * 
					FROM `' . pSQL(_DB_PREFIX_ . $this->table) . '_lang` 
					WHERE `' . $this->identifier . '` = ' . (int) $id);
                    if ($result) {
                        foreach ($result as $row) {
                            foreach ($row as $key => $value) {
                                if (key_exists($key, $this) and $key != $this->identifier) {
                                    if (!is_array($this->{$key})) {
                                        $this->{$key} = array();
                                    }
                                    $this->{$key}[(int) $row['id_lang']] = $value;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!is_array(self::$fieldsRequiredDatabase)) {
            $fields = $this->getfieldsRequiredDatabase(true);
            if ($fields) {
                foreach ($fields as $row) {
                    self::$fieldsRequiredDatabase[$row['object_name']][(int) $row['id_required_field']] = pSQL($row['field_name']);
                }
            } else {
                self::$fieldsRequiredDatabase = array();
            }
        }
    }
开发者ID:dlanileonardo,项目名称:correios,代码行数:65,代码来源:ObjectModel.php


注:本文中的ObjectModel::fieldsRequiredDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。