malikah Posted July 9, 2009 Share Posted July 9, 2009 I set a field in a MySQL table to VARCHAR with a size of 20. Is there a PHP command to get this size? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/ Share on other sites More sharing options...
Maq Posted July 9, 2009 Share Posted July 9, 2009 I set a field in a MySQL table to VARCHAR with a size of 20. Is there a PHP command to get this size? Cheers. Size as in bytes or character length? Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/#findComment-872056 Share on other sites More sharing options...
malikah Posted July 9, 2009 Author Share Posted July 9, 2009 I set a field in a MySQL table to VARCHAR with a size of 20. Is there a PHP command to get this size? Cheers. Size as in bytes or character length? Character length. Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/#findComment-872060 Share on other sites More sharing options...
Maq Posted July 9, 2009 Share Posted July 9, 2009 CHAR_LENGTH Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/#findComment-872064 Share on other sites More sharing options...
malikah Posted July 9, 2009 Author Share Posted July 9, 2009 CHAR_LENGTH Hmm, this doesn't seem to be what I'm after. I want PHP to go into the database and look at what the max size is set to for a particular column. I set the column to VARCHAR with a max size of 20. I want PHP to return the 20. Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/#findComment-872097 Share on other sites More sharing options...
malikah Posted July 9, 2009 Author Share Posted July 9, 2009 Achooo! scuse me... Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/#findComment-872136 Share on other sites More sharing options...
PFMaBiSmAd Posted July 9, 2009 Share Posted July 9, 2009 SHOW COLUMNS FROM your_table LIKE 'your_column'; or DESCRIBE your_table your_column; Either of these will return a 'Type' field that you can parse to get the size. Quote Link to comment https://forums.phpfreaks.com/topic/165359-use-php-to-find-the-size-of-a-mysql-tables-field/#findComment-872226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.