/** * @param Model $obj */ protected function do_insert(Model $obj) { $user = $this->user_dao->find(get_current_user_id()); $obj->set_creator($user); $obj->set_date(current_time('mysql')); $obj->set_date_gmt(current_time('mysql', 1)); $obj->set_modified($obj->get_date()); $obj->set_modified_gmt($obj->get_date_gmt()); // Create GUID. if (!$obj->get_guid()) { $site_url = get_site_url(); $hash = md5($obj->get_title() . $obj->get_date_gmt() . rand(0, 10000)); $obj->set_guid($site_url . '/?' . $hash); } $array = $this->create_array($obj); $format = $this->format(); $this->wpdb->insert($this->get_table(), $array, $format); $obj->set_id($this->wpdb->insert_id); $this->update_batch_content($obj); }