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 7824213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:31:25+00:00 2026-06-02T08:31:25+00:00

I have a script which generates my PHP models dynamically based on the structure

  • 0

I have a script which generates my PHP models dynamically based on the structure of my MySQL database. I get the list of tables with mysql_list_tables(), for each table get the list of fields with mysql_ list_ fields(), and depending on the table structure I create my methods accordingly: for instance if I find the integer field "order" defined, then my SELECT statements are ordered by the values of that field.

I would like to extend this approach by using the field flags returned by mysql_field_flags() to add internationalization support to by models. What I want is to add a custom flag type – in addition to the existing not_null, auto_increment and others – that I would for instance call i18n, then whenever a field has this flag set, I know I would need to add methods to fetch/add the values from a translation table. To allow me administrate the database (e.g. enable or disable translation on a field), it would be great if database administration interfaces like phpMyAdmin could automatically pick up on my custom flags.

Can I add custom flags to MySQL table fields, and have them picked up by phpMyAdmin and PHP?

  • 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-06-02T08:31:26+00:00Added an answer on June 2, 2026 at 8:31 am

    AFAIK there is no way to add custom flags to fields, as such. One way you could implement this is to us the COMMENT attribute with some kind of serialised data –

    CREATE TABLE test (
        id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
        color_id SMALLINT UNSIGNED NOT NULL COMMENT 'i18n'
    );
    

    I would advise against using the mysql_list_* functions for retrieving the table and field data. Instead you should select from the INFORMATION_SCHEMA. I would also suggest using PDO or mysqli as, with a bit of luck, the old mysql extension will be deprecated soon.

    Instead of mysql_list_tables() you would use –

    SELECT *
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = 'db_name'
    

    and instead of mysql_list_fields() you would use –

    SELECT *
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'db_name'
    AND TABLE_NAME = 'tbl_name'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a PHP script which generates an SQL file containing all tables
I have a php script (generator.php) which generates certain HTML/XML/SVG depending on various conditions.
I have a problem with following script. It generates a list of places which
I have a script which generates queries in the following fashion (based on user
I have a php script which generates an image, and is used (mainly) like
I have a php script which generates JS array in this form new Array(
I have a form which generates an HTML table using a PHP script on
I have a PHP script (news-generator.php) which, when I include it, grabs a bunch
I have a page which is largely created by DOM script, which generates a
I have got script which generates some graphic and returns it as a result,

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.