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

Not reloading page after php form submit
Hello helpful souls out there. You guys have come through for me in the recent past and I'm hoping s

Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:

http://www.mydomain.com/directory/index.php

Best way to cross matching large datasets
Hi,

Im running a script where am I cross matching about 200 000 data sets with each other. Ea

how can we add data from dynamic fields to mysql db in php
i have a script which i found on the internet. i modify that script according to my needs. what is i

Data Function is Its Not working IN IE8
This is my first time to use formums. I hope i can get solution for this problem. view plaincopy to

Call to undefined function mysql_fetch_accoc()
New to php/mysql coding. What's wrong with this sequence, or am I
just not seeing to obvious?

Variable passed to each() is not an array or object
Hi,

This is a email a friend type of form, and it isn't working anymore.

<?

MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an erro

problems with script
I made a small script wich exchanges points in my website:


<?php
session_start

How can I uploading Transactional Data from Legacy to New SAP system
Hell Gurus,

I am overwhelmed with questions on how to migrate huge volume of Sales Orders

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