0

私はphpとmysqlを使用しています。1 つのコマンドで複数のテーブルに挿入したい。これは、ストアド プロシージャまたは関数で実行できますか? もしそうなら、私はこの関数をphpで呼び出すことができますか?

例(疑似コード、私はmysqlでコーディングすることはあまりありません):

hash %list = {"ip", "network_table"; "gateway", "network_table"; "name", "server_table");

function lookup (string $s)
{
    //look up the value of s in a hash and return the corresponding table

    $table = $list[s]

    return $table;
}

function doTheInserting (hash $input) //or hash_ref? or array?
{
    for each $key in $input{
        $table = &lookup $key
        insert into $table ($key) values ($value)
    }
}

複数の「NOT NULL」列があると、いくつかの問題が発生します。これは実行可能な方法ですか?一度に複数のテーブルに情報を入力する必要がある場合、より良い方法はありますか?

4

0 に答える 0