I use this code:
select data_type from information_schema.columns where table_name = '$tableName' and column_name = '$column_name'
But after echo
, it's returning 1
. But when I run it in phpmyadmin sql it's returning data_type
of column.
I want data_type
of Mysql Table column (I'm using Wordpress).
Try this in wordpress. You should use get_var()
or get_row()
method.
$wpdb->query() returns only (int|false) Number of rows affected/selected or false on error
$dataType = $wpdb->get_var("select data_type from information_schema.columns where table_name = '$tableName' and column_name = '$column_name' ");
echo $dataType;exit;
Edited :
I have tried in my local like. you should try by setting these two varibale $tableName='wp_posts'; $column_name='post_title';
like below :
$tableName='wp_posts';
$column_name='post_title';
$data = $wpdb->get_var("select data_type from information_schema.columns where table_name = '$tableName' and column_name = '$column_name'");
echo $data;
Output
mediumtext
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With