2012-07-13 74 views
0

目前,此服務調用僅插入單個(1)記錄。不過,我需要能夠發送此方法要插入多個記錄的真實對象在此調用過程:PHP:處理記錄對象,而不僅僅是一條記錄

public function savePresentation($assets) { 

    $stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (presentationid, assetid, positionid) VALUES (?, ?, ?)"); 
    $this->throwExceptionOnError(); 

    mysqli_stmt_bind_param($stmt, 'iii', $assets->presentationid, $assets->assetid, $assets->positionid); 
    $this->throwExceptionOnError(); 

    mysqli_stmt_execute($stmt);  
    $this->throwExceptionOnError(); 

    $autoid = mysqli_stmt_insert_id($stmt); 

    mysqli_stmt_free_result($stmt);  
    mysqli_close($this->connection); 

    return $autoid; 
} 

我將如何改變這種做法,我可以通過一個關聯數組,或類似的東西?

我試過在foreach聲明中包裝聲明,但它似乎不起作用。 :/

備註:我從Flash發送數據,如果這很重要的話。

回答

0

使用error_log(print_r($ asset,true)) - 這會將您傳遞的對象的結構轉儲到PHP日誌中。然後你可以使用foreach或for/next或其他來循環它。也許你試圖循環一個不存在的結構,或者在傳入時格式不同?

它完全可以將複雜的對象從Flash/Flex傳遞到PHP。沒有理由你不能做你在這裏嘗試的東西。

相關問題