Skyfactor_interns
Skyfactor_interns

Reputation: 55

mysqli_result -- Need a string value from result

I have a query that returns the primary key of a table (this table is stored in an array of tables from a database) written in PHP:

$primaryKey = mysqli_query($link, "SHOW INDEX FROM ".$tables[$x]);

mysqli_query returns a mysqli_result, so what would be the best approach to get the string value of the primary key that I need from the variable that is returned?

Upvotes: 0

Views: 83

Answers (1)

ksbg
ksbg

Reputation: 3284

if(!$primaryKey = $link->query("SHOW INDEX FROM ".$tables[$x])) {
    die("Error! [" . $link->error . "]");
}

$result = $primaryKey->fetch_assoc();

$result should contain the index

Upvotes: 1

Related Questions