title: php and pdo skip some record to insert
body: <p>I am fetching rows from a CSV file but while inserting, some records were skipped. What is the solution for that?</p>
  
  <pre><code>while(($line = fgetcsv($file, 10000, ",")) !== FALSE){
  
              $total_data++;
               $sql="SELECT id FROM customers WHERE id ='".$line[0]."'";
              $db-&gt;query(  $sql);
  
              $check = $db-&gt;resultset();
              $num = $db-&gt;rowCount();
  
              if($num &gt; 0){
                  $update_data++;
                  //$db-&gt;query("UPDATE customers SET name = :name, phone=:phone where id=:id");
                  $db-&gt;bind(':name', $line[1]);
                  $db-&gt;bind(':phone', $line[2]);
                  $db-&gt;bind(':id', $line[0]);
                  $db-&gt;execute();
  
              }else{
                     $insert_data++;
                  $db-&gt;query("INSERT INTO customers(id,name,phone) VALUES (:id,:name,:phone)");
                      $db-&gt;bind(':id',$line[0]);
                      $db-&gt;bind(':name', $line[1]);
                      $db-&gt;bind(':phone', $line[2]);
                      $db-&gt;execute();
              }
          }
  </code></pre>