PHP mysql_fetch_object() ফাংশন
সংজ্ঞা ও ব্যবহার
mysql_fetch_object() ফাংশন ফলাফলের রেকর্ডসেট থেকে একটি সারি অবজেক্ট হিসাবে পাওয়া যায়。
যদি সফল হোক তবে, এই ফাংশন mysql_query() একটি সারি পাওয়া এবং একটি অবজেক্ট ফিরিয়ে দেওয়া। যদি ব্যর্থ হোক বা আর কোন সারি নেই, তবে false ফিরিয়ে দেওয়া হবে。
Syntax
mysql_fetch_object(data)
Parameter | Description |
---|---|
data | Required. The data pointer to use. This data pointer is from mysql_query() The returned results. |
Tips and Notes
Note:Each subsequent call to mysql_fetch_object() returns the next row in the record set.
Note:mysql_fetch_object() 与 mysql_fetch_array() Similarly, there is only one difference - it returns an object instead of an array. Indirectly, it also means that you can only access the array through field names, not offsets.
Example
<?php $con = mysql_connect("localhost", "peter", "abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person"; $result = mysql_query($sql,$con); while ($row = mysql_fetch_object($result)) { echo $row->FirstName . "<br />"; } mysql_close($con); ?>
Output:
John George Thomas