I am developing a tool that creates PHP classes based on tables in my database. Most of the functionality is based on data from SHOW COLUMNS FROM $table
. Each column typically relates to an instance variable in the new class being created.
What I have now is a situation where if a user passes in "twelve" for a variable related to a column of type INT, it doesn't fail, but the value in the database becomes 0.
What I would like is for the class to return false, identifying that the UPDATE
or INSERT
could not be completed.
What approach would you recommend for this?
What I'm trying now, is to construct an array of column names that contains each column that has a numeric data type (INT, FLOAT etc.). And when the user tries to set a variable, it checks to see if the variable is in this list and then checks the value being set to determine if it is a number.
PHP 5.3.3 using MySQLi
I'm assuming any column that isn't numeric will accept text data.