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


PHP DBConnect::get_last_insert方法代码示例

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


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

示例1: post_create

 /**
  *
  * @param <type> $post_origin_type
  * @param <type> $post_origin_id
  * @param <type> $content
  * @param <type> $order
  * @param <type> $parent the parent of the post... if this is set to zero,
  * then it assumes root
  */
 public function post_create(
         $post_origin_type,
         $post_origin_id,
         $content, $parent = 0, $order = false, $metadata = '')
 {
     self::validate_content($content, $this->post_datatype);
     if (!is_numeric($parent))
     {
         throw new DBForumException(
                 '$parent must be numeric');
     }
     if ($post_origin_type == null || $post_origin_type == "")
     {
         throw new DBForumException(
                 '$post_origin_type cannot be null or empty');
     }
     if (!is_null($post_origin_id) && !is_numeric($post_origin_id))
     {
         throw new DBForumException(
                 '$post_origin_id cannot be null or non numeric');
     }
     if (!is_bool($order) && !is_numeric($order))
     {
         throw new DBForumException(
                 '$order must be boolean or numeric');
     }
     if (!is_string($metadata))
     {
         throw new DBDataTypeException(
                 '$metadata must be a string');
     }
     try
     {
         if ($parent != 0)
         {
             if (null == $this->db->quick_query(
                     "SELECT ".self::POST_ID." FROM ".self::FCORE_FORUM_POST." WHERE
                         ".self::FORUM_ID."=$this->forum_id AND
                         ".self::POST_ID."=$parent", true))
             {
                 throw new Exception(
                         'parent id for the post does not exist in this thread');
             }
         }
         if (is_bool($order))
         {
             $order = $this->db->quick_query(
                     "SELECT max(".self::POSTORDER.") FROM ".self::FCORE_FORUM_POST." WHERE
                         ".self::POSTPARENT."=$parent AND
                         ".self::FORUM_ID."=$this->forum_id", true);
             if ($order == null)
             {
                 $order = 0;
             }
             else
             {
                 $order = $order[0]["max(".self::POSTORDER.")"];
                 $order++;
             }
         }
         $this->db->quick_query(
                 "INSERT INTO ".self::FCORE_FORUM_POST." SET
                     ".self::FORUM_ID."=$this->forum_id,
                     ".self::POSTPARENT."=$parent,
                     ".self::ORIGIN_ID."=$post_origin_id,
                     ".self::ORIGIN_TYPE."='$post_origin_type',
                     ".self::POSTORDER."=$order,
                     ".self::METADATA."='$metadata'");
         $post_id = $this->db->get_last_insert();
         DBDataType::CreateData(
                 self::build_datatype_origin($this->origin_type),
                 $post_id,
                 $this->post_datatype,
                 $content);
         $this->db->commit();
         return $post_id;
     }
     catch(Exception $e)
     {
         $this->db->rollback();
         throw new DBForumException($e->getMessage());
     }
 }
开发者ID:rexfleischer,项目名称:web_dev,代码行数:92,代码来源:DBForum.php

示例2: insert

 /**
  *
  * @param array $data 
  */
 public function insert(array $data)
 {
     try
     {
         $this->conn->quick_query(
                 "INSERT ".$this->config_map[self::DB_TABLE_NAME].
                     " SET ".$this->consume_data($data)
                 );
         $insert_id = $this->conn->get_last_insert();
         $this->conn->commit();
         return $insert_id;
     }
     catch(DBConnectException $e)
     {
         $this->conn->rollback();
         FCore::GetLogger()->log(Logger::LEVEL_ERROR, $e->getMessage());
         throw new DBFactoryException(
                 "An Error Occurred While Attempting To Insert: ", $e);
     }
 }
开发者ID:rexfleischer,项目名称:web_dev,代码行数:24,代码来源:DBFactory.php


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