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


PHP DataObject::dbinsert方法代码示例

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


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

示例1: dbinsert

 /**
  * Insert object into DB based on previously recorded changes.
  *
  * @return boolean true
  */
 function dbinsert()
 {
     global $DB, $localtimenow;
     $DB->begin();
     $this->set_param('timestamp', 'date', date2mysql($localtimenow));
     $result = parent::dbinsert();
     if ($result) {
         // Commit current transaction
         $DB->commit();
     } else {
         // Rollback current transaction
         $DB->rollback();
     }
     return $result;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:20,代码来源:_syslog.class.php

示例2: dbinsert

    /**
     * Insert object into DB based on previously recorded changes.
     */
    function dbinsert()
    {
        global $DB;
        $DB->begin();
        if (parent::dbinsert()) {
            global $Blog;
            // Update/Insert/Delete custom fields:
            $this->dbsave_custom_fields();
            if (!empty($Blog)) {
                // Enable this item type only for selected Blog:
                $DB->query('INSERT INTO T_items__type_coll
					       ( itc_ityp_ID, itc_coll_ID )
					VALUES ( ' . $this->ID . ', ' . $Blog->ID . ' )');
            }
        }
        $DB->commit();
    }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:20,代码来源:_itemtype.class.php

示例3: dbinsert

 /**
  * Insert object into DB based on previously recorded changes.
  */
 function dbinsert()
 {
     global $DB;
     $DB->begin();
     parent::dbinsert();
     // Create group permissions/settings for the current group
     $GroupSettings =& $this->get_GroupSettings();
     $GroupSettings->dbupdate($this->ID);
     $DB->commit();
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:13,代码来源:_group.class.php

示例4: dbinsert

 /**
  * Insert into the DB
  */
 function dbinsert()
 {
     global $DB;
     $DB->begin();
     if (parent::dbinsert()) {
         if (isset($this->CollectionSettings)) {
             // So far all settings have been saved to collection #0 !
             // Update the settings: hackish but the base class should not even store this value actually...
             // dh> what do you mean? What "base class"? Is there a problem with CollectionSettings?
             $this->CollectionSettings->cache[$this->ID] = $this->CollectionSettings->cache[0];
             unset($this->CollectionSettings->cache[0]);
             $this->CollectionSettings->dbupdate();
         }
     }
     $DB->commit();
 }
开发者ID:LFSF,项目名称:oras,代码行数:19,代码来源:_blog.class.php

示例5: dbinsert

    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            // Save IP Range and user counter
            antispam_increase_counter('user');
        }
        $DB->commit();
        return $result;
    }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:46,代码来源:_user.class.php

示例6: die

    /**
     * Insert message in existing thread
     *
     * @return true if success, instead false
     */
    function dbinsert_message()
    {
        global $DB, $localtimenow;
        if ($this->ID != 0) {
            die('Existing object cannot be inserted!');
        }
        $DB->begin();
        $this->get_Thread();
        $this->Thread->set_param('datemodified', 'string', date('Y-m-d H:i:s', $localtimenow));
        if ($this->Thread->dbupdate()) {
            $this->set_param('thread_ID', 'integer', $this->Thread->ID);
            if (parent::dbinsert()) {
                $sql = 'UPDATE T_messaging__threadstatus
						SET tsta_first_unread_msg_ID = ' . $this->ID . '
						WHERE tsta_thread_ID = ' . $this->Thread->ID . '
							AND tsta_user_ID <> ' . $this->author_user_ID . '
							AND tsta_first_unread_msg_ID IS NULL';
                $DB->query($sql, 'Insert thread statuses');
                // check if contact pairs between sender and recipients exists
                $recipient_list = $this->Thread->load_recipients();
                // remove author user from recipient list
                $recipient_list = array_diff($recipient_list, array($this->author_user_ID));
                // insert missing contact pairs if required
                if ($this->dbinsert_contacts($recipient_list)) {
                    if ($this->dbupdate_last_contact_datetime()) {
                        $DB->commit();
                        $this->send_email_notifications(false);
                        return true;
                    }
                }
            }
        }
        $DB->rollback();
        return false;
    }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:40,代码来源:_message.class.php

示例7: dbinsert

    /**
     * Insert object into DB based on previously recorded changes.
     *
     * @return boolean true on success
     */
    function dbinsert()
    {
        global $DB;
        if ($this->ID != 0) {
            debug_die('Existing object cannot be inserted!');
        }
        $DB->begin();
        $order_max = $DB->get_var('SELECT MAX(wi_order)
				 FROM T_widget
				WHERE wi_coll_ID = ' . $this->coll_ID . '
					AND wi_sco_name = ' . $DB->quote($this->sco_name), 0, 0, 'Get current max order');
        $this->set('order', $order_max + 1);
        $res = parent::dbinsert();
        $DB->commit();
        return $res;
    }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:21,代码来源:_widget.class.php

示例8: dbinsert

 /**
  * Get karma and set it before adding the Comment to DB.
  *
  * @return boolean true on success, false if it did not get inserted
  */
 function dbinsert()
 {
     /**
      * @var Plugins
      */
     global $Plugins;
     global $Settings;
     // Get karma percentage (interval -100 - 100)
     $spam_karma = $Plugins->trigger_karma_collect('GetSpamKarmaForComment', array('Comment' => &$this));
     $this->set_spam_karma($spam_karma);
     // Change status accordingly:
     if (!is_null($spam_karma)) {
         if ($spam_karma < $Settings->get('antispam_threshold_publish')) {
             // Publish:
             $this->set('status', 'published');
         } elseif ($spam_karma > $Settings->get('antispam_threshold_delete')) {
             // Delete/No insert:
             return false;
         }
     }
     $dbchanges = $this->dbchanges;
     if ($r = parent::dbinsert()) {
         $Plugins->trigger_event('AfterCommentInsert', $params = array('Comment' => &$this, 'dbchanges' => $dbchanges));
     }
     return $r;
 }
开发者ID:LFSF,项目名称:oras,代码行数:31,代码来源:_comment.class.php

示例9: dbinsert

    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            /* Save IP Range -- start */
            $ip = int2ip(ip2int($_SERVER['REMOTE_ADDR']));
            // Convert IPv6 to IPv4
            if (preg_match('#^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$#i', $ip)) {
                // Check IP for correct format
                $ip_24bit_start = ip2int(preg_replace('#\\.\\d{1,3}$#i', '.0', $ip));
                $ip_24bit_end = ip2int(preg_replace('#\\.\\d{1,3}$#i', '.255', $ip));
                if ($iprange = get_ip_range($ip_24bit_start, $ip_24bit_end)) {
                    // Update ip range
                    $DB->query('UPDATE T_antispam__iprange
									SET aipr_user_count = ' . $DB->quote($iprange->aipr_user_count + 1) . '
									WHERE aipr_ID = ' . $DB->quote($iprange->aipr_ID));
                } else {
                    // Insert new ip range
                    $DB->query('INSERT INTO T_antispam__iprange ( aipr_IPv4start, aipr_IPv4end, aipr_user_count )
									VALUES ( ' . $DB->quote($ip_24bit_start) . ', ' . $DB->quote($ip_24bit_end) . ', ' . $DB->quote('1') . ' ) ');
                }
            }
            /* Save IP Range -- end */
        }
        $DB->commit();
        return $result;
    }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:63,代码来源:_user.class.php

示例10: dbinsert

 /**
  * Insert object into DB based on previously recorded changes.
  *
  * @return boolean true on success
  */
 function dbinsert()
 {
     global $DB, $localtimenow;
     load_funcs('items/model/_item.funcs.php');
     if ($this->ID != 0) {
         die('Existing object cannot be inserted!');
     }
     // Start transaction because of urltitle validation
     $DB->begin('SERIALIZABLE');
     // validate url title / slug
     $this->set('urlname', urltitle_validate($this->urlname, $this->name, $this->ID, false, $this->dbprefix . 'urlname', $this->dbIDname, $this->dbtablename));
     $this->set_param('last_touched_ts', 'date', date('Y-m-d H:i:s', $localtimenow));
     if (parent::dbinsert()) {
         // The chapter was inserted successful
         $DB->commit();
         return true;
     }
     // Could not insert the chapter object
     $DB->rollback();
     return false;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:26,代码来源:_chapter.class.php

示例11: dbinsert

 /**
  * Insert object into DB based on previously recorded changes
  *
  * @return boolean true on success, false on failure
  */
 function dbinsert()
 {
     global $Debuglog;
     if ($this->meta == 'unknown') {
         debug_die('cannot insert File if meta data has not been checked before');
     }
     if ($this->ID != 0 || $this->meta != 'notfound') {
         debug_die('Existing file object cannot be inserted!');
     }
     $Debuglog->add('Inserting meta data for new file into db', 'files');
     // Let's make sure the bare minimum gets saved to DB:
     $this->set_param('root_type', 'string', $this->_FileRoot->type);
     $this->set_param('root_ID', 'integer', $this->_FileRoot->in_type_ID);
     $this->set_param('path', 'string', $this->_rdfp_rel_path);
     // Let parent do the insert:
     $r = parent::dbinsert();
     // We can now consider the meta data has been loaded:
     $this->meta = 'loaded';
     return $r;
 }
开发者ID:LFSF,项目名称:oras,代码行数:25,代码来源:_file.class.php

示例12: dbinsert

    /**
     * Insert into the DB
     */
    function dbinsert()
    {
        global $DB, $Plugins, $Settings;
        $DB->begin();
        if ($this->get('order') == 0) {
            // Set an order as max value of previous order + 1 if it is not defined yet
            $SQL = new SQL();
            $SQL->SELECT('MAX( blog_order )');
            $SQL->FROM('T_blogs');
            $max_order = intval($DB->get_var($SQL->get()));
            $this->set('order', $max_order + 1);
        }
        $set_default_blog_ID = isset($Settings);
        if (get_setting_Blog('default_blog_ID')) {
            // Don't set a default blog if it is already defined and the blog exists in DB
            $set_default_blog_ID = false;
        }
        if ($set_default_blog_ID) {
            // No default blog yet, Use for first base url as "Default collection on baseurl"
            $this->set('access_type', 'baseurl');
        } else {
            // For all other blogs use "Extra path on index.php"
            $this->set('access_type', 'extrapath');
        }
        if (parent::dbinsert()) {
            if ($set_default_blog_ID) {
                // Use this blog as default because it is probably first created
                $Settings->set('default_blog_ID', $this->ID);
                $Settings->dbupdate();
            }
            if (isset($this->CollectionSettings)) {
                // So far all settings have been saved to collection #0 !
                // Update the settings: hackish but the base class should not even store this value actually...
                // dh> what do you mean? What "base class"? Is there a problem with CollectionSettings?
                $this->CollectionSettings->cache[$this->ID] = $this->CollectionSettings->cache[0];
                unset($this->CollectionSettings->cache[0]);
                $this->CollectionSettings->dbupdate();
            }
            $default_post_type_ID = $this->get_setting('default_post_type');
            if (!empty($default_post_type_ID)) {
                // Enable post type that is used by default for this collection:
                global $DB;
                $DB->query('INSERT INTO T_items__type_coll
									 ( itc_ityp_ID, itc_coll_ID )
						VALUES ( ' . $DB->quote($default_post_type_ID) . ', ' . $DB->quote($this->ID) . ' )');
            }
            // Enable default item types for the inserted collection:
            $this->enable_default_item_types();
            $Plugins->trigger_event('AfterCollectionInsert', $params = array('Blog' => &$this));
        }
        $DB->commit();
    }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:55,代码来源:_blog.class.php

示例13: dbinsert

 /**
  * Insert object into DB based on previously recorded changes.
  *
  * @return boolean true on success, false on failure to insert
  */
 function dbinsert()
 {
     global $DB;
     $dbchanges = $this->dbchanges;
     $DB->begin();
     if (($r = parent::dbinsert()) !== false) {
         // Update types of the Files
         $this->update_file_types();
         $DB->commit();
     } else {
         $DB->rollback();
     }
     return $r;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:19,代码来源:_filetype.class.php

示例14: dbinsert

 /**
  * Insert object into DB based on previously recorded changes
  *
  * @return boolean true on success, false on failure
  */
 function dbinsert()
 {
     global $Debuglog;
     if ($this->meta == 'unknown') {
         debug_die('cannot insert File if meta data has not been checked before');
     }
     if ($this->ID != 0 || $this->meta != 'notfound') {
         debug_die('Existing file object cannot be inserted!');
     }
     $Debuglog->add('Inserting meta data for new file into db', 'files');
     // Let's make sure the bare minimum gets saved to DB:
     $this->set_param('root_type', 'string', $this->_FileRoot->type);
     $this->set_param('root_ID', 'number', $this->_FileRoot->in_type_ID);
     $this->set_param('path', 'string', $this->_rdfp_rel_path);
     $this->set_param('path_hash', 'string', md5($this->_FileRoot->type . $this->_FileRoot->in_type_ID . $this->_rdfp_rel_path, true));
     if (!$this->is_dir()) {
         // create hash value only for files but not for folders
         $this->set_param('hash', 'string', md5_file($this->get_full_path(), true));
     }
     // Let parent do the insert:
     $r = parent::dbinsert();
     // We can now consider the meta data has been loaded:
     $this->meta = 'loaded';
     return $r;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:30,代码来源:_file.class.php

示例15: dbinsert

 /**
  * Get karma and set it before adding the Comment to DB.
  *
  * @return boolean true on success, false if it did not get inserted
  */
 function dbinsert()
 {
     /**
      * @var Plugins
      */
     global $Plugins;
     global $Settings;
     // Get karma percentage (interval -100 - 100)
     $spam_karma = $Plugins->trigger_karma_collect('GetSpamKarmaForComment', array('Comment' => &$this));
     $this->set_spam_karma($spam_karma);
     // Change status accordingly:
     if (!is_null($spam_karma)) {
         if ($spam_karma < $Settings->get('antispam_threshold_publish')) {
             // Publish:
             $this->set('status', 'published');
         } elseif ($spam_karma > $Settings->get('antispam_threshold_delete')) {
             // Delete/No insert:
             return false;
         }
     }
     // set comment secret for quick moderation
     // fp> users have requested this for all comments
     $comment_Item =& $this->get_Item();
     $comment_Blog =& $comment_Item->get_Blog();
     if ($comment_Blog->get_setting('comment_quick_moderation') != 'never') {
         // quick moderation is permitted, set comment secret
         $this->set('secret', generate_random_key());
     }
     $dbchanges = $this->dbchanges;
     if ($r = parent::dbinsert()) {
         if ($this->is_published()) {
             // Update last touched date of item if comment is created in published status
             $comment_Item->update_last_touched_date();
         }
         $Plugins->trigger_event('AfterCommentInsert', $params = array('Comment' => &$this, 'dbchanges' => $dbchanges));
     }
     return $r;
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:43,代码来源:_comment.class.php


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