RE: [PHP-DB] Re: No data?
| From: | Brad | Date: | Fri, 27 Jul 2012 05:09:56 +0000 |
| Subject: | RE: [PHP-DB] Re: No data? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48383@lists.php.net to get a copy of this message | ||
No, it did not work.
mysql> show tables;
+--------------------+
| Tables_in_mailList |
+--------------------+
| testBook1csv |
+--------------------+
1 row in set (0.00 sec)
mysql> select * from
testBook1csv;
+----+--------+
| id | field0 |
+----+--------+
| 1 | NULL |
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
| 5 | NULL |
| 6 | NULL |
+----+--------+
6 rows in set (0.00 sec)
file upload example
$_FILES
array(1) {
["userfile"]=>
array(5) {
["name"]=>
string(13) "testBook1.csv"
["type"]=>
string(24) "application/octet-stream"
["tmp_name"]=>
string(14) "/tmp/phpiaW23p"
["error"]=>
int(0)
["size"]=>
int(102)
}
}
ls -l /tmp/phpiaW23p
-rw------- 1 apache apache 102 Jul 27 00:02 /tmp/phpiaW23p
$sql for create table
string(110) "create table if not exists testBook1csv (id integer not null
auto_increment primary key, field0 varchar(50))"
$sql for load data
string(142) "load data local infile '/tmp/phpiaW23p' into table
testBook1csv fields terminated by ',' optionally enclosed by
'"' lines terminated by '\n'"
Verify data contents
Table testBook1csv
string(28) "select * from testBook1csv"
$sql=
data
array(2) {
[0]=>
string(1) "1"
[1]=>
NULL
}
array(2) {
[0]=>
string(1) "2"
[1]=>
NULL
}
array(2) {
[0]=>
string(1) "3"
[1]=>
NULL
}
array(2) {
[0]=>
string(1) "4"
[1]=>
NULL
}
array(2) {
[0]=>
string(1) "5"
[1]=>
NULL
}
array(2) {
[0]=>
string(1) "6"
[1]=>
NULL
}
-----Original Message-----
From: tamouse mailing lists [mailto:tamouse.lists@gmail.com]
Sent: Thursday, July 26, 2012 11:20 PM
To: Brad
Cc: jim.giner@albanyhandball.com; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?
Brad, do take a look at http://pastie.org/4340383 It does
work.