روز برنامه‌نویس مبارک 🤩🎉 از هدایای روز برنامه‌نویس جا نمونی ⌛
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ امیرعلی رمضانی
در مورد pdo
جامعه پی اچ پی ایجاد شده در ۱۶ فروردین ۱۴۰۱
fetchColumn()

چیکار میکنه

سلام دوست عزیز

PDOStatement::fetchColumn — Returns a single column from the next row of a result set

طبق دایکیومنت PHP این متد میاد طبق ورودی int اولین ستون (n + 1) رو بر میگردونه و اگر اون ستون نباشه false برمیگردونه

توجه شما رو به مثال زیر جلب میکنم

$sth $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
print("Fetch the first column from the first row in the result set:\\n");
$result $sth->fetchColumn(); // inja ma chizi behesh pass nadadim va avalin sotoon bar migarde
print("name = $result\\n");
print("Fetch the second column from the second row in the result set:\\n");
$result $sth->fetchColumn(1); // inja ma 1 behesh pass nadadim va dovomin sotoon bar migarde
print("colour = $result\\n");
بهترین پاسخ
محمد گازری ۱۶ فروردین ۱۴۰۱، ۱۷:۵۳