Multiple transactions on a single InnoDB table possible?
<p>This is a question regarding SQL, but the aim is to create a php script.</p>

<p><strong>CONTEXT</strong></p>

<p>Let say I have one database containing 2 tables (set on InnoDB engine) :</p>

<ul>
<li>users</li>
<li>cart</li>
</ul>

<p>Now 2 users access my application (in php), and both launch a web page that is doing the following algorithm :</p>

<ol>
<li>Open the connection</li>
<li>Open a transaction</li>
<li>Insert a new line in the table user</li>
<li>Commit the transaction</li>
</ol>

<p><strong>QUESTION</strong></p>

<p>Can SQL handle 2 transactions on the same table ? </p>

<p><strong>PhP Code (for the record)</strong></p>

<pre><code>$host = 'localhost';
$database = 'user';
$user = 'root';
$password = '';
$encode = 'utf8';
$dsn = "mysql:host=$host;dbname=$database;charset=$encode";
$pdo = null;

try {
    $pdo = new PDO($dsn, $user, $password);
    $query = "INSERT INTO user (name, city) VALUES ('test', 'Paris')";
    $pdo-&gt;beginTransaction();

    if( $pdo-&gt;inTransaction() ) {
        // Can I still launch the query ?
    }
    else {
        // Or should I stop here ?
    }

    if( $pdo-&gt;query( $query ) ) {
        $pdo-&gt;commit();
    }
    else {
        $pdo-&gt;rollBack();
    }   
}
catch( PDOException $e ) {
    print_r($pdo-&gt;errorInfo());
}
</code></pre>