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

Select all entries from database that include a phrase
I have a database of clubs - one of the categories is meeting time and place
I would like to have

Find occurences of unicode characters in string
I need to prohibit filenames with everything but English characters and numbers but regexp and strin

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

database design
Hi,

I got a page which allow candidate to type in their previous working experience,
I let

Help with form post data and arrays
Hi all,

I am new to this forum... It has been awhile since i have worked with arrays, and i a

help, header() is not working!
Hello, I have this code:


<?php

/**
* @author samoi
* @copyright 200

Help with usergroups? prolly really quick
So were coding our own forums for a game system we made an we have the users level setup but now I n

Blank record injected into database
I always found several blank records inside my database, although $SESSION is required to insert the

Help with php code
Hello, can anyone tell me why this php word trap fails to work,
and the trigger words get blow r

COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i

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