S
S
Sergey2016-03-18 15:33:07
PHP
Sergey, 2016-03-18 15:33:07

MySQL: LOAD DATA INFILE. How to save existing value in database?

What is:
A site for transferring water readings, and viewing current debt.
There are more than 100,000 personal accounts in the database.
What the site is made on:
PHP, MySQL
How the process of updating debts takes place:
Create a file in txt format, it contains the necessary fields, the key field is the account number.
Separation goes through ';'.
This file loads all faces into the database. accounts with the necessary information.
The request itself:

$query = "LOAD DATA INFILE '".$filename."' REPLACE INTO TABLE `account` FIELDS TERMINATED BY ';' (`id`,`lastname`,`street`,`house`,`housing`,`apartment`,`debt`,`balans`)";

Everything is recorded perfectly, there are no problems with this.
My problem:
When the user, after registering, binds persons. account to your account, the following happens.
We take the number of persons. we find the accounts in the database, see if the user is attached to it.
If not bound, then bind the current user. (there is a userId field)
And when in a month the time to update the debt data comes up. We also write to the database via LOAD DATA INFILE.
The data is updated, but the userId field becomes empty.
This is my problem. I read, I searched, I tried. But I could not implement updating only the fields I needed. It should be noted that there are more than 100,000 personal accounts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2016-03-18
@seregali

store a bunch of id and user_id separately...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question