columncount : Number of Columns Present in the query
By using PDO MySQL function columncount() we can get number of columns present in the query.
Here is the code to get total field numbers present in the table
<?Php
require "config.php"; // Database connection string
$count=$dbo->prepare("select * from pdo_admin ");
$count->execute();
echo "Number of Columns : ". $count->columnCount();
?>
The output will be
Number of Columns : 5
Query can be changed like this
$count=$dbo->prepare("select id,userid from pdo_admin ");
The output will be
Number of Columns : 2
← PDO References rowcount() →
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com