Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7179833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:13:15+00:00 2026-05-28T17:13:15+00:00

I am developing a tool that creates PHP classes based on tables in my

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:13:16+00:00Added an answer on May 28, 2026 at 5:13 pm

    What are you are asking is called ORM. There are some good ORM libraries in PHP.

    1. Doctrine
    2. Propel
    3. Outlet ORM
    4. Leap ORM for Kohana ( I use it )
    5. PHP Data Mapper

    BTW, I answer your question.

    If any invalid data is set you can throw an Exception.

    See a sample.

    class MyTable extends DbTable{
        function __set($var, $val){
            switch($var){
                case 'age': // age should be numeric type
                    if(!is_numeric($val)){
                        throw new InvalidDataTypeException("$val of $var is not numeric");
                    }
                 /// do other operation here
    
                 ... 
                 ... // more cases
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a tool to dump data from variables. I need to dump
I am developing a tool that handles some database entities using JPA2, with hibernate
I'm developing on super fast fibre optic connection. I want a tool that allows
I'm developing a diagnostic tool on a PC with several Network Interfaces based on
I'm developing a tool that accesses SVN by running the command line SVN to
I am in the process of developing a desktop application that needs a database.
I'm developing an iPhone app that uses the built-in SQLite database. I'm trying to
I'm developing a tool that lets you open multiple pages at once with a
I'm developing web application on python. But the client wants a tool that exports
I have been developing a WCF project that will expose web services (HTTP-based) that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.