title: Prevent same row being selected in mySQL
body: <p>I have been given the task of creating a "Mass Crawler" which completely relies on proxies inside a database. Here's a simple overview in what I'm attempting to achieve : </p>
  
  <ul>
  <li>1 x CronJob Bootstrap file - This is the file which sends 50 parallel <strong>curl</strong> requests to the <strong>individual crawler</strong> file</li>
  <li>1 x Individual Crawler file - This is supposed to grab a <strong>UNIQUE</strong> row (proxy) from the database which another process hasn't selected.</li>
  </ul>
  
  <p>I've had a look into the <code>TRANSACTIONS</code> with mySQL, but I still believe doing this wouldn't help as the query would be getting executed at the exact same time for each individual crawler process.</p>
  
  <p>Here's kind of the idea I had in my head for the individual crawler file :</p>
  
  <pre><code>$db = new MysqliDb("localhost", "username", "password", "database");
  
  $db-&gt;connect();
  $db-&gt;startTransaction();
  $db-&gt;where("last_used", array("&lt;" =&gt; "DATE_SUB(NOW(),INTERVAL 30 SECOND)"));
  $proxies = $db-&gt;get("proxies", 1);
  if(count($proxies) == 1) {
  
      //complete any scraping that needs to be done
  
      //update the database to say the proxy has just been used
      $db-&gt;where("id", $accounts[0]['id']);
      $db-&gt;update("proxies", array("last_used", date("Y-m-d H:i:s")));
  
      //commit the complete transaction
      $db-&gt;commit();
  }
  $db-&gt;disconnect();
  </code></pre>
  
  <p>Would that above example be the correct way to use the mySQL <code>TRANSACTION</code> feature and assure <strong>ALL</strong> parallel queries selected different rows? </p>