Re: [PHP-DB] Newbie file reading into MySQL

2003-07-07 Thread Jason Wong
On Monday 07 July 2003 07:44, Kim Kohen wrote:

  Just one question: why are you storing text files containing DATA into a
  DB? Why not just store the data in the DB and do away with the text
  files?

 
 Thanks for the reply.  I can see now my original wording was a bit unclear.
 I am, in fact, storing the data only - the text file is just the 'conduit'
 to get data from InDesign into PHP.  InDesign will generate the text file
 - PHP reads in the data from the file (and than deletes the text file) -
 MySQL stores it - PHP will report on it.

 It's just a matter of how to format the file from InDesign. The two options
 would be line by line eg:

 Kim
 Page 8
 Sunday, 6 July 2003 8:08:46 PM
 Ad number 1234-t32
 Ad placed on page

 I'm figuring this way I'd have to use fgets() and go line by line and do 5
 separate INSERTs or I could have it as some kind of list eg:

 Kim, Page 8, Sunday, 6 July 2003 8:08:46 PM, Ad number 1234-t32, Ad placed
 on page

 If I do this and get the list into an array, can I have an INSERT statement
 along the lines of INSERT INTO test (column1, column2, column3, column4,
 column5) VALUES ($myarray)  or do I have to parse the array into individual
 values before INSERTing?

You can't pass the array directly like that.

 Logically I'd see one INSERT statement being better than five - I'm just
 not sure how to handle the INSERT from an array.

You have to address each element of the array explicitly:

INSERT INTO test (column1, column2, column3, column4, column5) VALUES 
($myarray[0], $myarray[1], ...)

 -or- (depending on how you constructed your array:

INSERT INTO test (column1, column2, column3, column4, column5) VALUES 
($myarray['column1'], $myarray['column2'], ...)

You may want to investigate whether formatting the file into something that 
can be read by fgetcsv() or parse_ini_file() would make things easier.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
If people drank ink instead of Schlitz, they'd be better off.
-- Edward E. Hippensteel

[What brand of ink?  Ed.]
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Newbie file reading into MySQL

2003-07-06 Thread Jason Wong
On Sunday 06 July 2003 19:04, Kim Kohen wrote:

[snip]

 I'm trying to build a PHP/MySQL workflow tracking system in which each
 movement of an InDesign  file generates a text file which contains the
 tracking data I want to move into the  (MySQL) db.  It will contain the
 operators name, a timestamp and a status (incomplete, pending, complete
 etc)

[snip]

Just one question: why are you storing text files containing DATA into a DB? 
Why not just store the data in the DB and do away with the text files?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
If you improve or tinker with something long enough, eventually it will break 
or malfunction
-- Murphy's In Laws n8
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Newbie file reading into MySQL

2003-07-06 Thread Kim Kohen
G'day Jason

 Just one question: why are you storing text files containing DATA into a DB?
 Why not just store the data in the DB and do away with the text files?

Thanks for the reply.  I can see now my original wording was a bit unclear.
I am, in fact, storing the data only - the text file is just the 'conduit'
to get data from InDesign into PHP.  InDesign will generate the text file -
PHP reads in the data from the file (and than deletes the text file) -
MySQL stores it - PHP will report on it.

It's just a matter of how to format the file from InDesign. The two options
would be line by line eg:

Kim
Page 8
Sunday, 6 July 2003 8:08:46 PM
Ad number 1234-t32
Ad placed on page

I'm figuring this way I'd have to use fgets() and go line by line and do 5
separate INSERTs or I could have it as some kind of list eg:

Kim, Page 8, Sunday, 6 July 2003 8:08:46 PM, Ad number 1234-t32, Ad placed
on page

If I do this and get the list into an array, can I have an INSERT statement
along the lines of INSERT INTO test (column1, column2, column3, column4,
column5) VALUES ($myarray)  or do I have to parse the array into individual
values before INSERTing?

Logically I'd see one INSERT statement being better than five - I'm just not
sure how to handle the INSERT from an array.

Cheers and thanks

kim


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php