Question about DB & accessing fixed records from local C:\ .txt file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • applegreenss@gmail.com

    Question about DB & accessing fixed records from local C:\ .txt file

    Is it possible to take the contents of a MySQL DB Table, and somehow
    put the data into a syntax-correct data file format like a delimited
    ..txt file, and using PHP parse it as a local c:\ file assuming it was
    sitting in C:\data.txt ..... so I want to read its contents in a
    similar method as you would query a DB table .... can you do this the
    same with a blob of data stored in a .TXT file?

    If so, how to format .txt & php code -- I would very much like to
    emulate this scenario against a c:\ stored .txt file:

    <?
    $sql_query = "SELECT * FROM localfile WHERE value = '$somevalue'";
    $result = @mysql_query($s ql_query,$db);

    // now put all the data into arrays
    $a = 0;
    while ($row = mysql_fetch_row ($result)) {

    $somearray1[$a] = $row[0];
    $somearray2[$a] = $row[1];

    $a++;
    }
    ?>

    Can something like this be done? :)

  • Rik

    #2
    Re: Question about DB &amp; accessing fixed records from local C:\ .txt file

    applegreenss@gm ail.com wrote:
    Is it possible to take the contents of a MySQL DB Table, and somehow
    put the data into a syntax-correct data file format like a delimited
    .txt file, and using PHP parse it as a local c:\ file assuming it was
    sitting in C:\data.txt ..... so I want to read its contents in a
    similar method as you would query a DB table .... can you do this the
    same with a blob of data stored in a .TXT file?
    >
    If so, how to format .txt & php code -- I would very much like to
    emulate this scenario against a c:\ stored .txt file:
    >
    <?
    $sql_query = "SELECT * FROM localfile WHERE value = '$somevalue'";
    $result = @mysql_query($s ql_query,$db);
    >
    // now put all the data into arrays
    $a = 0;
    while ($row = mysql_fetch_row ($result)) {
    >
    $somearray1[$a] = $row[0];
    $somearray2[$a] = $row[1];
    >
    $a++;
    }

    Not really an answer to your question, but maybe an answer to your actual
    problem/reason for wanting this:
    SQLite uses only files, hardly any administration needed, check it out:
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.



    Offcourse it's totally possible to dump a mysql database in sqlite, with
    most of the major normal sql functionality intact.
    --
    Rik Wasmus


    Comment

    • C.

      #3
      Re: Question about DB &amp; accessing fixed records from local C:\ .txt file


      applegreenss@gm ail.com wrote:
      Is it possible to take the contents of a MySQL DB Table, and somehow
      put the data into a syntax-correct data file format like a delimited
      .txt file,
      Yes - take a look at mysqldump, but it might be simpler to roll your
      own.
      and using PHP parse it as a local c:\ file assuming it was
      sitting in C:\data.txt ..... so I want to read its contents in a
      similar method as you would query a DB table
      Yes - IIRC there's an ODBC driver for CSV files (but the last time I
      used it was about 10 years ago - maybe MS don't ship it any more).
      >.... can you do this the
      same with a blob of data stored in a .TXT file?
      >
      Yes - but you'll need to encode it first. A better solution would be to
      write each blob to its own file and reference the file from the table.

      Although it is *possible* to do all this, it doesn't make a lot of
      sense - a better solution would be SQLite or DBM.

      C.

      Comment

      Working...