473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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($sql_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? :)

Dec 11 '06 #1
2 1113
Rik
ap**********@gmail.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($sql_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:
http://www.php.net/manual/en/ref.sqlite.php
http://sqlite.org/

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

ap**********@gmail.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.

Dec 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing...
14
by: CJM | last post by:
I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is: ----------------------------------------------------------...
3
by: Jake McDermott | last post by:
We have a few developers that use Oracle 9i (9.2.0.4.0) on their personal workstations for testing purposes. Recently, weve made the decision to upgrade them to WinXP so that they are able to use...
3
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I...
36
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
22
by: roadrunner | last post by:
Hi, Our website has recently been experiencing some problems under load. We have pinpointed a particular function which slows dramatically when we have these problems. Normally it should execute...
2
by: JJA | last post by:
I'm looking at some code I do not understand: var icons = new Array(); icons = new GIcon(); icons.image = "somefilename.png"; I read this as an array of icons is being built. An element of...
1
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.