473,385 Members | 1,356 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.

Modifying MySQL Result - but not the DB

Hi,

How can I modify a MySQL data set returned by mysql_query? I am
basically doing a while loop over the rows, changing one field, and
then doing a mysql_data_seek back to the beginning of the set before
returning it. However, later calls to mysql_fetch_assoc still return
the orginal data, meaning that (I assume) I am changing a copy of the
data rather than the result set itself. Taking the reference (i.e.
$record =& mysql_fetch_assoc($result);) did not help.

I have read a large quantity of the posts in the php.net site,
googled, and read my PHP books - but have come up short on this one.

Yes, I know it's better to simply modify the DB. However, I'm working
with an existing code base which is very complicated, and want to
cherry pick one very well tested feature by making a change in the
result set only under special circumstances.

Thanks,
Ed Eichman
Cambrils, Spain
Jul 17 '05 #1
3 1586
Ed Eichman wrote:
Hi,

How can I modify a MySQL data set returned by mysql_query? I am
basically doing a while loop over the rows, changing one field, and
then doing a mysql_data_seek back to the beginning of the set before
returning it.


Are you doing the same calc to a field in every row? Or is there an "if"
involved. Anyway, why not try to put the "logic" into the sql statement that
creates the recordset. Look at the MySQL documentation on how to use an
embeded "iif" statement. That might be the best solution. You can do a hell
of a lot of logic in SQL if you learn how.

The other solution would be to get the result set into an array or maybe even
a temp table and then bounce down it and do what you want to do.

Al
Adams-Blake Company, Inc.
***
JAYA123 - the new web-based total-office system for the
small biz. Order entry, billing, bookkeeping, etc. for $14.95
a month. Everyone says "It's cool as a moose!!"
See why at:http://www.jaya123.com ('ja-eye-ah' means
'victory' in Sanskrit.)
***

Jul 17 '05 #2
Hi Al,

Thanks for the quick answer...
Are you doing the same calc to a field in every row? Or is there an "if"
involved. Anyway, why not try to put the "logic" into the sql statement that
creates the recordset. Look at the MySQL documentation on how to use an
embeded "iif" statement. That might be the best solution. You can do a hell
of a lot of logic in SQL if you learn how.
I'll check this out.
The other solution would be to get the result set into an array or maybe even
a temp table and then bounce down it and do what you want to do.


Not possible - the "downstream" code uses the query result - moving it
to an array would break the downstream code.

Thanks,
Ed
Jul 17 '05 #3
On 13 Jun 2004 00:05:22 -0700, ei*******@hotmail.com (Ed Eichman)
wrote:
The other solution would be to get the result set into an array or maybe even
a temp table and then bounce down it and do what you want to do.


Not possible - the "downstream" code uses the query result - moving it
to an array would break the downstream code.


so a temporary table could do the trick. Just pass the sql statement
refering to the temporary table.

This will work only, id your "downstream" code will use the temporary
table right away, without a new connection to the database, because
the temporary will be erased after the connection is lost.

Regards

Marian

--
Tipps und Tricks zu PHP, Coaching und Projektbetreuung
http://www.heddesheimer.de/coaching/
Jul 17 '05 #4

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

Similar topics

8
by: William Drew | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.databases.mysql This is an invitation to discuss the following proposal to create newsgroup comp.databases.mysql. Please note that YOU...
4
by: Ben | last post by:
Hi I am new to C++ and I want to know if C++ is suitable for making a GUI application with a MySQL database. I also want to know what keywords in books I should look for. Is DATA STRUCTURES a...
4
by: Ka | last post by:
I install a mysql server in default installation with latin charset, but I want to use GBK(a chinese charset), so that I can store and search chinese words directly. so, I download, unpack and...
3
by: auron | last post by:
Hi there, I have a really stupid and banal problem with showing the results of a MySQL query in PHP, preciselly with MySQL count() function that gives to a variable in PHP the result. NOTE:...
0
by: IamtheEvster | last post by:
Hi All, I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am unable to call a MySQL stored procedure that returns output parameters using mysql, mysqli, or PDO. I'm having a...
1
by: paulq182 | last post by:
PLEASE HELP ME WITH MY CODE?? import java.sql.*; import java.io.*; class min_filmdb_rel_mysql { public static void main (String args ) throws SQLException, IOException {
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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.