コード例 #1
0
ファイル: vivvo_post.php プロジェクト: ahanjir07/vivvo-dev
 /**
  * Inserts new row to table
  *
  * @return boolean
  * @access private
  */
 function sql_insert($commit = true, $id = false)
 {
     if ($this->_check_data() === true and !empty($this->_data_in)) {
         if ($id !== false) {
             $this->_data_in[$this->id_key] = $id;
         } else {
             if (isset($this->_data_in[$this->id_key])) {
                 unset($this->_data_in[$this->id_key]);
             }
         }
         $sql = $this->prepare_insert($this->_data_in);
         $sm = vivvo_lite_site::get_instance();
         if (!PEAR::isError($sql)) {
             $sm->debug_push("sql:", $sql->query);
             if ($commit == true || !vivvo_lite_site::get_instance()->get_db()->supports('transactions')) {
                 $hook = 'db_' . get_class($this->data_object) . '_insert';
                 if (vivvo_hooks_manager::call($hook . '_pre', array(&$this)) !== false) {
                     $res = $sql->execute($this->_data_in);
                     if (PEAR::isError($res)) {
                         $sm->debug_push("sql:", $res->getMessage(), 1);
                         return false;
                     }
                     vivvo_hooks_manager::call($hook . '_post', array(&$this));
                 } elseif (!vivvo_hooks_manager::get_status()) {
                     return false;
                 }
             } else {
                 $this->stack[] = $sql;
             }
         } else {
             $sm->debug_push("sql:", $sql->getMessage(), 1);
         }
         /**
          * call on_insert method
          *
          * {@link vivvo_post_object::on_insert}
          */
         if (is_a($this->data_object, 'vivvo_post_object')) {
             $this->data_object->on_insert($this);
         }
     } else {
         return false;
     }
     $this->metod = 'insert';
     return true;
 }