columncount : Number of Columns Present in the query

PHP PDO & MYsQL 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
require "config.php"; // Database connection string

$count=$dbo->prepare("select * from pdo_admin ");
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


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer