Extract integer from mysql via PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clai83
    New Member
    • Dec 2007
    • 41

    Extract integer from mysql via PHP

    mysql and mysqli functions always return strings values, and I understand that I can set the type of the data via the settype function AFTER I extract the data, but is there a way with PHP to extract the data as it is specified in the mysql database? (i.e if the type is an integer then PHP will insert the integer value in the result set).

    The reason I ask is I want to create a function to verify the integrity of the database before I process it and if I can skip creating a function using regex to check if the value is an integer I would go that route.

    Any help is appreciated
  • aktar
    New Member
    • Jul 2006
    • 105

    #2
    Instead of extracting the data from the db and checking it, why dont you check the database itself?


    try this : SHOW FULL COLUMNS FROM [YOUR TABLE]


    more info:
    http://dev.mysql.com/doc/refman/5.0/en/show-columns.html

    Comment

    • clai83
      New Member
      • Dec 2007
      • 41

      #3
      Originally posted by aktar
      Instead of extracting the data from the db and checking it, why dont you check the database itself?


      try this : SHOW FULL COLUMNS FROM [YOUR TABLE]


      more info:
      http://dev.mysql.com/doc/refman/5.0/en/show-columns.html
      Good idea, Thanks man.

      Now this question has turned into a MYSQL question.

      Is it possible to do some simple data integrity checks using queries? For example checking to see if a particular column has only alphanumeric characters in its data, or something like that.

      Comment

      Working...