第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在更新查詢中獲取 lastInsertId 的問(wèn)題

在更新查詢中獲取 lastInsertId 的問(wèn)題

PHP
SMILET 2021-08-27 09:24:06
我正在開(kāi)發(fā)用于 oop php 中的屬性/廣告的 cms 以用于學(xué)習(xí)目的。我有三個(gè)與數(shù)據(jù)透視表相連的表。photos (name, extension, created_at, updated_at), property_photo (property_id, photo_id), properties (title, description, type_of_property, use_of_the_property, quadrature, location...) 當(dāng)我嘗試通過(guò)添加另一張照片來(lái)更新我的屬性時(shí),在我的數(shù)據(jù)透視表中 photo_id 從照片表中獲取正確的 id,但我的 property_id 始終為 0。現(xiàn)在我知道 lastInsertId 函數(shù)僅在 INSERT 上不能用于 UPDATE 但我不知道如何以不同的方式獲取 property_id。任何幫助表示贊賞。這是我在模型中的功能:廣告模型:public function update_ad($data, $id){    $this->db->query('UPDATE properties SET title=:title, description=:description, type_of_property=:type_of_property, use_of_the_property=:use_of_the_property, quadrature=:quadrature, location=:location, price=:price, sales_clerk_info=:sales_clerk_info, booked=:booked, type_of_market=:type_of_market, type_of_payment=:type_of_payment WHERE id=:id');    $this->db->bind(':title', $data['title']);    $this->db->bind(':description', $data['description']);    $this->db->bind(':type_of_property', $data['type_of_property']);    $this->db->bind(':use_of_the_property', $data['use_of_the_property']);    $this->db->bind(':quadrature', $data['quadrature']);    $this->db->bind(':location', $data['location']);    $this->db->bind(':price', $data['price']);    $this->db->bind(':sales_clerk_info', $data['sales_clerk_info']);    $this->db->bind(':booked', $data['booked']);    $this->db->bind(':type_of_market', $data['type_of_market']);    $this->db->bind(':type_of_payment', $data['type_of_payment']);    $this->db->bind(':id', $id);    $this->db->execute();    $property_last_id = $this->db->lastId();    $dataimagecount = count($data['image']);    for ($i=0; $i < $dataimagecount ; $i++) {     $extension[$i] = explode('.',$data['image'][$i]);    $this->db->query('INSERT INTO photos (name, extension) VALUES (:name, :extension)');    $this->db->bind(':name', $extension[$i]['0']);    $this->db->bind(':extension', $extension[$i]['1']);    $this->db->execute();
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 161 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)