توابع mysql_field_flags() در PHP

تعریف و استفاده

توابع mysql_field_flags() نشانه‌های مرتبط با فیلد مشخص شده را از نتایج می‌گیرد.

این تابع نشانه‌های فیلد مورد نظر را برمی‌گرداند.

اگر نسخه MySQL به‌روز باشد، از نشانه‌های زیر پشتیبانی خواهد کرد:

  • auto_intcrement
  • binary
  • blob
  • enum
  • multiple_key
  • not_null
  • primary_key
  • timestamp
  • unique_key
  • unsigned
  • zerofill

Syntax

mysql_field_flags(data,field_offset)
Parameter Description
data Required. The data pointer to be used. The data pointer is from mysql_query() The returned result.
field_offset Required. Indicates from which field to return. 0 indicates the first field.

Tips and Comments

Tip:Each flag is represented by a word, separated by a space, so you can use the explode() function to split the returned string into an array.

Example

<?php
$con = mysql_connect("localhost", "hello", "321");
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);
$flags = mysql_field_flags($result, 0);
echo $flags;
mysql_close($con);
?>

Output:

not_null primary_key auto_increment