insert/update functions for mysql, what do you think?


Posted on 16th Feb 2014 07:03 pm by admin

I am working on two really simple functions that automatically generate (and execute) insert and update mysql queries and I have some questions:

Can there be any problems later on if functions treat numeric and string values the same? The function reports error if some value is neither numeric nor string (checked by using is_numeric and is_string functions), otherwise it just uses mysql_real_escape_string on all values in array and adds '' everywhere. Unlike microsoft access, mysql doesn't seem to care if you put '' on numeric value.

The simplest usage of insert function (for form data entry) would be:

db_insert('users', 'name,e_mail,bio', $_REQUEST);

First argument is table, another is the list of fields (separated by comma) , and third is the associative array of data that you want to insert.

Can you notice any problems?

No comments posted yet

Your Answer:

Login to answer
329 Like 10 Dislike
Previous forums Next forums
Other forums

Most basic form question ever?
Hello,

I want to use this snippet to make sure the fields in a form are ok before processing

Xacute search within SQL results
I have a query that is pulling data, and I want to return a specific value from the results of that

All possible combinations of Strings from table in PL/SQL
Hi,

I am trying to figure out how to build a list of all possible string combinations fro

TimeZoneOffset
Hello,

Please i need your help. I have a system that users can use to punch in and out. This

Text to picture Generator
Hello, i have found this script and it works really good^^ But i have one problem, i would like to c

IIS on 2003 anon access disabled issue
I have an IIS server that belongs to a domain, and anonymous access is turned off for all my sites.

Get relative path from absolute path
How would one go about getting the relative path to a file from its absolute path?

How To Make More Than One Redirection with PHP on the same page?
Hey im trying to do a direction page where it open differently link direction pages every time som

How to read CSS message data
Hi,
I have a requirement here. When working as a Dev angel for multiple customers its really di

Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash