2013-08-01 91 views
0

(INSERT + On DuplicateKey UPDATE)+ UPDATE?INSERT in one table and UPDATE in another table

  • 我想$合併獲取和$ get2在MySQL
  • process方法是兩個表中準備好的聲明
  • 的值($_SESSION['val1'])列索引(外鍵)連接。

代碼:

$get = $call->process("INSERT INTO table1 VALUES (?, ?, ?, ?, UTC_TIMESTAMP(), 0) 
ON DUPLICATE KEY 
UPDATE col4 = ?, col5 = UTC_TIMESTAMP()", 
array($_SESSION['val1+val2'], $_SESSION['val1'], $_SESSION['val2'], 'OK', 'NOOK')); 

    if($get) 
    { 
    $get2 = $call->process("UPDATE table2 SET col8 = col8 + 1 WHERE colval1 = ?", 
       array($_SESSION['val1'])); 
    } 

我應該使用存儲過程?

回答

相關問題