We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
  • 2
Inputting Data into MySQL using PHP
Topic Started: Feb 11 2005, 12:01 PM (759 Views)
Zero Tolerance
Being me is not a good thing.
[ *  *  * ]
They are both only written for mySQL databases at the current moment (unless IPB 2.0 made it for another one? I'm not sure).

Anyway implode/explode are used to turn strings to arrays and vice versa, compiling them into valid SQL syntax would probably mean you have to put them in a function of your own, so it would be pointless using those.

The insert one come's in very hand either way, especially if your inserting into specific fields into a table, plus you can use the functions to validate the data being sent in, saving you more code and time. The main objective of functions is to cut coding quantity, does it not?

- Zero Tolerance
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
True, I'm not familiar with vB, but yeah, IPB can use a number of different engines including MSSQL and Oracle.

Explode an array's keys using comma delimiters, I have my columns. Explode the same array's values using commas, there are the values. Just seems pointless to reinvent the wheel.

My point is not that it may or may not reduce your code to 3 lines less than the expanded method. But if I have to look outside the query to see what variables and values I am passing in, that translates into reduced code readability, which means I might have to take twice as long going over a function I wrote a week ago. I would much rather have 10 lines of code and know instantly what they do, than have 6 and have to guess.
Offline Profile Quote Post Goto Top
 
Zero Tolerance
Being me is not a good thing.
[ *  *  * ]
You would just review the array with the keys and data to see what was being updated/inserted.

But i guess that's just me, i hate to have function passive variables on multi-line, ie:

Code:
 
myfunction("omg
new line
weeee
!!");


I prefer it all to be one one short line.

- Zero Tolerance
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
Eh? What does that have to do with passing arrays to explode? :huh:

But why in the world would you put true delimiters in?

$n = "\n";
myFunction("oh noes" . $n . "I's better" . $n . "than j00");

Or with regards to readibility, say hello to the multi-line query ^_^

$query = "UPDATE blahyou SET" .
"boo = 'hiss', yay = 'me', you = 'suck'" .
"WHERE 'me' > 'you'";

mysql_query($query);
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1
  • 2