S
S
sickgang2020-04-27 12:38:06
PHP
sickgang, 2020-04-27 12:38:06

How to remove id and insert auto increment?

Hello!
There is a table that I import into the database through a PHP script:

$columns = "`id`,`pid`,`sort`,`name`,`region`,`city`,`street`,`house`,`descr`,`contact_person`,`tel`,`email`,`manager`,`foto`,`coords`,`randhash`,`activity`";
if ( ($handle_o = fopen($_SERVER["DOCUMENT_ROOT"]."/local/help/partners_20200331.csv", "r") ) !== FALSE ) {
    while ( ($data_o = fgetcsv($handle_o, 1000, ";")) !== FALSE) {
      $insertValues = array();
      foreach( $data_o as $v ) {
         $insertValues[]="'".addslashes(trim($v))."'";
      }
      $values = implode(',',$insertValues);
      $values = iconv('CP1251', 'UTF-8', $values);
      // $sql = "INSERT INTO `partners_adresses` ($columns) VALUES ($values)";
      // $res = $DB->Query($sql, false, $err_mess.__LINE__);
    }
}
fclose($handle_o);


But I need the id not to be picked up from the table, but inserted automatically sequentially, how can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kuznetsov, 2020-04-27
@dima9595

So remove the id's from the request to get from the csv file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question