我正在尝试从 php 的另一个视图创建一个视图,但我没有收到任何错误,但它很简单不会创建一个视图。我可以在 mysql 控制台中从另一个手动创建视图,但不能从 php 手动创建视图。知道我哪里出错了吗?
function createTransaction_file($db,$file_id){
$sql = "CREATE VIEW transaction_file AS SELECT context,transaction_type,starttime,stoptime,stoptime - starttime AS runtime,correlator,parent_correlator,iteration FROM transactions WHERE file_id =" . $file_id . " ORDER BY starttime" ;
//echo $sql;
if($stmt = $db->prepare($sql)){
/* execute query */
$stmt->execute();
}else{
echo "File id is ". $file_id;
echo "Error code ({$db->errno}): {$db->error}";
die("Could not create transaction_iter view");
}
/* close statement */
$stmt->close();
}
function createTransaction_iter($db,$iteration){
$sql = "CREATE VIEW transaction_iter AS SELECT context,transaction_type,starttime,stoptime,stoptime - starttime AS runtime,correlator,parent_correlator,iteration FROM transaction_file WHERE iteration = ".$iteration." LIMIT 500;" ;
//echo $sql;
if($stmt = $db->prepare($sql)){
/* execute query */
$stmt->execute();
}else{
echo "File id is ". $file_id;
echo "Error code ({$db->errno}): {$db->error}";
die("Could not create transaction_iter view");
}
/* close statement */
$stmt->close();
}
createTransaction_file($db,$file_id);
createTransaction_iter($db,$iteration);