SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot Rotwang's Avatar
    Join Date
    Jun 2005
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Standardized Class for db table defnition?

    In my code right now I'm making classes that represents the tables and columns in my db. Like,

    Code:
    class DBField {
    
    public $type; //bigint, varchar, etc
    public $auto_increment; //bool
    public $isprimarykey; //bool
    public $unique; //bool
    
    ..etc etc
    
    }
    Is there like a standard class for this already? I don't want to reinvent the wheel if there's already a standard for this like in Pear or something.

    (UPDATE: I edited this post after arborint's response)
    Last edited by Rotwang; Jun 10, 2005 at 22:33.

  2. #2
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That looks like a class to represent a database column/field rather than a table.
    Christopher

  3. #3
    SitePoint Zealot Rotwang's Avatar
    Join Date
    Jun 2005
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea that's what I meant to say.

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to take a look at what some of the DB abstraction and OR libraries use.
    Christopher

  5. #5
    SitePoint Zealot Rotwang's Avatar
    Join Date
    Jun 2005
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where would I get those from? is that part of pear?

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For what you want to do, there is an article on www.onlamp.com which may help you. It's PHP5 only though (uses reflection API) but it's a start.

    With a bit of work, the classes can be ported to PHP4.x, namely overcoming the Reflection

  7. #7
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't let this pass without mentioning the ADOdb library.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •