php pdo get database name
$pdo->query('select database()')->fetchColumn();
php pdo get database name
$pdo->query('select database()')->fetchColumn();
Fetching Columns Using PDO (PHP DATA OBJECT)
Code:
$conn = new PDO("mysql:host=localhost;dbname=db_user", "root", "");
$query = $conn->prepare("SELECT * FROM tbl_user WHERE id > ?");
$query->execute([10]);
$result = $query->fetchAll(PDO::FETCH_COLUMN, 1);
echo "<pre>";
print_r($result);
echo "</pre>";
Output:
Array
(
[0] => Fatema Akter
[1] => Roksana Akter
[2] => Syed Fahim
[3] => Tonmoy Ahmed
[4] => Jannatul Ferdous
[5] => Mahabuba Rahman Porshi
[6] => Kaium Ahmed
[7] => Rabbi Islam
[8] => Md. Fahad Monshi
[9] => Arif Hossain
)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us