2012-07-13 73 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。没有理由你不能做你在这里尝试的东西。

相关问题