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. 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? 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. 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 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. 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... 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. 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
Archived
This topic is now archived and is closed to further replies.