nonethefewer: (Default)
[personal profile] nonethefewer
PHP/MySQL question.

There is a tab-separated file that contains, among other things, true/false values.

I run this from the command line:

mysqlimport -v --fields-terminated-by='\t' --fields-optionally-enclosed-by="'" --lines-terminated-by='\n' --user=user --password=password dbname filename.csv

The true/false values are updated fine.

I do the exact same damn thing from PHP, and all true/false columns are set to false.

What gives?

[eta] Same if I run this in PHP:

mysql_query("LOAD DATA INFILE '$file' INTO TABLE table_name FIELDS TERMINATED BY '\t' ENCLOSED BY \"'\" LINES TERMINATED BY '\n'");

WRYYYYYYYy

Originally posted on Dreamwidth.  Number of comments so far: comment count unavailable

(no subject)

Date: 2010-07-15 05:48 am (UTC)
siderea: (Default)
From: [personal profile] siderea
No idea. If I were going to make a guess, I would investigate:

1) whether "ENCLOSED BY \"'\"" actually does equal "--fields-optionally-enclosed-by="'"", particularly the optional part, and

2) Whether the escaping \"'\" was doing the right thing, especially if you magic quotes on or something.

(no subject)

Date: 2010-07-15 07:05 am (UTC)
From: [identity profile] the-xtina.livejournal.com
I wrote the command to the page, so I could see how it looked afters.  There are differences between PHP-command and command-line-command, but none affect the command itself.  (Piping to a logfile, frex.)

I tracked down something that said going from [some data type] to boolean to varchar resulted in doom, but it is too late o'clock for me to think right now.  I recall their opinion being to change the data type of the destination column to char, and hopefully that'd help.

February 2022

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728     

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 10th, 2025 04:54 am
Powered by Dreamwidth Studios