Jump to content

Get Column Indextype in Mysql-table with API


kixe
 Share

Recommended Posts

How can I get the index type of a mysql database table with pw-api? The Following doesn't work. Why?

$table = 'pages';
$column = 'pages_id';

$sql1 = $db->query("SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$column'");
$options = array();
while ($row = $sql1->fetch_array()) $options[] = $row;
var_dump($options); // return empty array
Link to comment
Share on other sites

pages_id is not a column in pages, I think you are looking for 'id'.

Results for query('SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='pages'):

+-------------------+
| COLUMN_NAME       |
+-------------------+
| id                |
| parent_id         |
| templates_id      |
| name              |
| status            |
| modified          |
| modified_users_id |
| created           |
| created_users_id  |
| sort              |
+-------------------+
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...