Solved

mysql query:   name vs. order-based;  mysqli

Posted on 2013-01-16
3
349 Views
Last Modified: 2013-02-10
i'm inheriting code that i need to fix and add features to.
they use order-based queries and there are some bugs due to incorrect index order-matching with the SELECT argument list.

1.  mysql_fetch_array is used with $row[1]  where the index corresponds to the SELECT arg order.
     i'm accustomed to mysql_fecth_assoc  where the field name is used and order is inconsequential (and much more reliable for maintenance, etc.)

is there any aspect i should be aware of regarding converting from   _array     to    _assoc?
intuitively it seems trivial to just change the function name, and replace the index with $row['fieldname']
There are 33 fields in one query, so you can imagine the spaghetti code!

2.  is there any argument change between using  mysql and myslqi  system function calls?
can i just blindly substitute for all combinations of mysql_*  function names

thanks!
0
Comment
Question by:willsherwood
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 38785983
1/  => I also only use _array if by design of the relevant code, I will use the column by index, usually if there IS only 1 or 2 columns to be extracted.

2/ some input here:
http://stackoverflow.com/questions/548986/mysql-vs-mysqli-in-php
my opinion is that if already you want to do the change, you should consider a rewrite using the full options of the new classes. otherwise you could as well leave the old code...
0
 

Author Comment

by:willsherwood
ID: 38787201
for #1,  are there any gotchas (or surprises) for converting back and forth  for _array  vs.   _index
0
 

Author Closing Comment

by:willsherwood
ID: 38874269
appreciate your help
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now