mysql_result
��������� ������������� ���� ����������.
��������� :
int mysql_result(int result, int row [, mixed field])
������� ���������� �������� ���� field � ������ ���������� � ������� row.�������� field ����� �������� �� ������ ��� ����, �� � ��� ����� - �������, �� ������� ������� "�����" ��� �������� �������, � ����� ������ ��� ���� ����: "���_�������.���_����". ��� �� �����, ������������� �����, ��� ��� ������ ��������,������������ ������ ����� �����.
������� ������������: � �� ������� ����� "������" ���� ��������� �� ����� ������. � ���� ��� �� ������������, �� ������, ������, �� �������������, �.�. mysql_result() �������� �������� ��������.
��������� ������������� ���� ����������.
��������� :
int mysql_result(int result, int row [, mixed field])
������� ���������� �������� ���� field � ������ ���������� � ������� row.�������� field ����� �������� �� ������ ��� ����, �� � ��� ����� - �������, �� ������� ������� "�����" ��� �������� �������, � ����� ������ ��� ���� ����: "���_�������.���_����". ��� �� �����, ������������� �����, ��� ��� ������ ��������,������������ ������ ����� �����.
������� ������������: � �� ������� ����� "������" ���� ��������� �� ����� ������. � ���� ��� �� ������������, �� ������, ������, �� �������������, �.�. mysql_result() �������� �������� ��������.
mysql_fetch_array
��������� �� ���������� ��������� ������ � �������� �� � ������������� ������.
��������� :
array mysql_fetch_array(int result [, int result_type])
������� mysql_fetch_array() ���������� ��������� ������ ���������� � ���� �������������� �������, ��� ������� ���� ����������� ������� � ������, ����������� � ������ ����. ������������� � ������ ������������ �������� � ��������� ������� � ����������, ���������������� ��������� ����� � ����� ���������. � ������������ ������� ��� ����������� ����� �� ���������� � "��������" �������.
�������� result_type ������ ��� ������������� ������� � ����� ��������� ���� �� ��������� ��������: MYSQL_NUM, MYSQL_ASSOC, MYSQL_BOTH (�� ���������).
����� ���������� ������: ����� ������ ����� �������� �������. ����� �����: ���� � ���, ��� � ���������� ������� � ���������������� ����� �������������� ���� (����������, �������) � ����������� �������, ��, ��������������, � ���������� ���������. ��� ���������� �����, ����� ������� � SELECT ������������ ������������ �� ���������� ������.
��������� �� ���������� ��������� ������ � �������� �� � ������������� ������.
��������� :
array mysql_fetch_array(int result [, int result_type])
������� mysql_fetch_array() ���������� ��������� ������ ���������� � ���� �������������� �������, ��� ������� ���� ����������� ������� � ������, ����������� � ������ ����. ������������� � ������ ������������ �������� � ��������� ������� � ����������, ���������������� ��������� ����� � ����� ���������. � ������������ ������� ��� ����������� ����� �� ���������� � "��������" �������.
�������� result_type ������ ��� ������������� ������� � ����� ��������� ���� �� ��������� ��������: MYSQL_NUM, MYSQL_ASSOC, MYSQL_BOTH (�� ���������).
����� ���������� ������: ����� ������ ����� �������� �������. ����� �����: ���� � ���, ��� � ���������� ������� � ���������������� ����� �������������� ���� (����������, �������) � ����������� �������, ��, ��������������, � ���������� ���������. ��� ���������� �����, ����� ������� � SELECT ������������ ������������ �� ���������� ������.
mysql_connect($host, $user, $pass); $result=mysql_db_query("database", "select id, name from tabl"); while($row=mysql_fetch_array($result)) { echo "id: ".$row["id"]."<BR>"; echo "id: ".$row[0]."<BR>"; echo "name: ".$row["name"]."<BR>"; echo "name: ".$row[1]."<BR>"; }; mysql_free_result($result);
mysql_fetch_row
���������� ������ � ������������ ������.
��������� :
array mysql_fetch_row(int result)
������� ���������� ������-������ �� ���������� ����� ��������� ������ ���������� result. ���� ��������� ������� ������� ���������� ��� ���������� �� ��������� ������� (�� ���� ������ ���������), ������������ false. ������� ������� ���������� � ��������� ������, ��� ��� ��������� ����� mysql_fetch_row() ������ ��������� ������ ����������.
������ ���� ������ ����������� � ������������ �������� �������. ��������� ���������� � 0.
���������� ������ � ������������ ������.
��������� :
array mysql_fetch_row(int result)
������� ���������� ������-������ �� ���������� ����� ��������� ������ ���������� result. ���� ��������� ������� ������� ���������� ��� ���������� �� ��������� ������� (�� ���� ������ ���������), ������������ false. ������� ������� ���������� � ��������� ������, ��� ��� ��������� ����� mysql_fetch_row() ������ ��������� ������ ����������.
������ ���� ������ ����������� � ������������ �������� �������. ��������� ���������� � 0.
$r=mysql_query("select * from OutTable where age<30"); while($Row=mysql_fetch_row($r)) { // ������������ ������ $Row }��� �����, ���� ���������, ��� ������ ������ ����������, �.�. ����� mysql_fetch_row() ������ false.
mysql_fetch_object
��������� ������ � ��������� �������.
��������� :
object mysql_fetch_object(int result)
������� ���������� ������, � ��������� �������� ��������� ���� ������� ������. � ������, ���� ������ ���������, ���������� false.
��������� ������ � ��������� �������.
��������� :
object mysql_fetch_object(int result)
������� ���������� ������, � ��������� �������� ��������� ���� ������� ������. � ������, ���� ������ ���������, ���������� false.
mysql_connect($host, $user, $pass); $result=mysql_db_query("database", "select * from table"); while($rows=mysql_fetch_object($result)) { echo $rows->id; echo $rows->name; };
mysql_fetch_lengths
���������� ����� �������� ������.
��������� :
array mysql_fetch_lengths(int result)
������� mysql_fetch_lengths() ���������� ����� ��������, ����������� ��� ������ ������� mysql_fetch_row(), mysql_fetch_array() ��� mysql_fetch_object().
��������, � ��������� �������:
���������� ����� �������� ������.
��������� :
array mysql_fetch_lengths(int result)
������� mysql_fetch_lengths() ���������� ����� ��������, ����������� ��� ������ ������� mysql_fetch_row(), mysql_fetch_array() ��� mysql_fetch_object().
��������, � ��������� �������:
$arr=mysql_fetch_row($result); $len=mysql_fetch_lengths($result);������ $len ����� ��������� ����� ��������������� ��������� ������� $arr, �.�. $len[0]=strlen(arr[0]) � �.�.
mysql_fetch_field
���������� ���������� � ��������� ������� � � ���� ������.
��������� :
object mysql_fetch_field(int result [, int field_offset])
� �������������� ��������� field_offset �������� ����� ����, �������� �������� �� ����� ��������. ���� ���� �������� �� ������, ��� ������ ������� ������� mysql_fetch_field() ������������ �������� ���������� ���� �� ������ ������� result.
������������ ������ ����� ��������� ��������:name - ��� ����
table - ��� �������, ������� ����������� ����
max_length - ������������ ����� ����
not_null - 1, ���� ���� ��������� ������ ��������
primary_key - 1, ���� ���� �������� ��������
unique_key - 1, ���� � ���� ����������� ������ ���������� ��������
multiple_key - 1, ���� � ���� ��������� ����� ������������� ��������
numeric - 1, ���� ���� ��������
blob - 1, ���� ���� ����� ��� BLOB
type - ��� ����
unsigned - 1, ���� ���� �������� �����������
zerofill - 1, ���� ���� ����������� ������
���������� ���������� � ��������� ������� � � ���� ������.
��������� :
object mysql_fetch_field(int result [, int field_offset])
� �������������� ��������� field_offset �������� ����� ����, �������� �������� �� ����� ��������. ���� ���� �������� �� ������, ��� ������ ������� ������� mysql_fetch_field() ������������ �������� ���������� ���� �� ������ ������� result.
������������ ������ ����� ��������� ��������:
mysql_connect($host,$user,$pass); $result=mysql_db_query("database", select * from table"); for($i=0;$i<mysql_num_fields($result);$i++) { echo "�������� ���� $i:<BR>"; $param=mysql_fetch_field($result); if(!$param) echo "��� ���������� � ���������!"; echo "<PRE> name: $param->name table: $param->table max_length: $param->max_length not_null: $param->not_null primary_key: $param->primary_key unique_key: $param->unique_key multiple_key: $param->multiple_key numeric: $param->numeric blob: $param->blob type: $param->type unsigned: $param->unsigned zerofill: $param->zerofill </PRE>"; }
mysql_field_seek
���������� ����������� ������� � ���������� ����.
��������� :
int mysql_field_seek(int result, int field_offset)
������ ������� �������� ��������. ��������� ��������� ����� ������������:
���������� ����������� ������� � ���������� ����.
��������� :
int mysql_field_seek(int result, int field_offset)
������ ������� �������� ��������. ��������� ��������� ����� ������������:
$param=mysql_fetch_field($result, field_offset); � mysql_field_seek($result, field_offset); $param=mysql_fetch_field($result);
mysql_field_name
���������� ��� ����.
��������� :
string mysql_field_name(int result, int filed_index)
������� mysql_field_name() ���������� ��� ����, ������� ����������� � ���������� result � �������� filed_index (��������� ���������� � 0).
���������� ��� ����.
��������� :
string mysql_field_name(int result, int filed_index)
������� mysql_field_name() ���������� ��� ����, ������� ����������� � ���������� result � �������� filed_index (��������� ���������� � 0).
$result=mysql_query("SELECT id, name from table"); echo mysql_field_name($result,1); // �������: name
mysql_field_table
���������� ��� �������, �� ������� ���� ��������� ����.
��������� :
string mysql_field_table(int result, int field_offset)
���������� ��� �������, �� ������� ���� ��������� ���� �� ��������� field_offset � ���������� result.
���������� ��� �������, �� ������� ���� ��������� ����.
��������� :
string mysql_field_table(int result, int field_offset)
���������� ��� �������, �� ������� ���� ��������� ���� �� ��������� field_offset � ���������� result.
mysql_field_len
���������� ����� ����.
��������� :
int mysql_field_len(int result, int filed_offset)
������� ���������� ����� ���� � ���������� result. ����, ��� ������, �������� ��������� ��� ��������. ��� ������ ����� ��������������� �� ������ ������ ���� � ������, � ��� ������, ������� ��� ������ ��� ��� ��������. ��������, ���� ���� ����� ��� varchar � ���� ������� (������ � ��������) � ����� varchar(100), �� ��� ���� ����� ���������� 100.
���������� ����� ����.
��������� :
int mysql_field_len(int result, int filed_offset)
������� ���������� ����� ���� � ���������� result. ����, ��� ������, �������� ��������� ��� ��������. ��� ������ ����� ��������������� �� ������ ������ ���� � ������, � ��� ������, ������� ��� ������ ��� ��� ��������. ��������, ���� ���� ����� ��� varchar � ���� ������� (������ � ��������) � ����� varchar(100), �� ��� ���� ����� ���������� 100.
mysql_field_type
���������� ��� ������ ������� � ����������.
��������� :
string mysql_field_type(int result, int filed_offset)
��� ������� ������ �� mysql_filed_name(), ������ ���������� �� ��� , � ��� ��������������� ������� � ����������. �� ����� ����, ��������, int, double, real � �.�.
���������� ��� ������ ������� � ����������.
��������� :
string mysql_field_type(int result, int filed_offset)
��� ������� ������ �� mysql_filed_name(), ������ ���������� �� ��� , � ��� ��������������� ������� � ����������. �� ����� ����, ��������, int, double, real � �.�.
mysql_connect($host,$user,$pass); mysql_select_db("mydb"); $result=mysql_query("SELECT * FROM tabl"); $fields=mysql_num_fields($result); $rows=mysql_num_rows($result); $i=0; $table=mysql_field_table($result,$i); echo "������� "$table" ����� $fields ����� � $rows �������<BR>"; echo "��������� �������:<BR>"; while($i<$fields) { $type=mysql_field_type($result,$i); $name=mysql_field_name($result,$i); $len=mysql_field_len($result,$i); $flags=mysql_field_flags($result,$i); echo $type." ".$name." ".$len." ".$flags."<BR>"; $i++; }
mysql_field_flags
��� ������� ���������� �����, ������� ���� ������������ ��� �������� ���������� ���� � �������.
��������� :
string mysql_field_flags(int result, int field_offset)
������������ ������ ������������ ����� ����� ����, ����������� ���������, ��� ��� �� ������ ������������� �� � ������ ��� ������ ������� explode():
"not_nul", "primary_key", "unique_key", "multiple_key", "blob", "unsigned", "zerofill", "binary", "enum", "auto_increment", "timestamp".
��� ������� ���������� �����, ������� ���� ������������ ��� �������� ���������� ���� � �������.
��������� :
string mysql_field_flags(int result, int field_offset)
������������ ������ ������������ ����� ����� ����, ����������� ���������, ��� ��� �� ������ ������������� �� � ������ ��� ������ ������� explode():
$Flags=explode(" ",mysql_field_flags($r,$field_offset));���� ������� � MySQL ����� ����� ��������� ��������-�����:
"not_nul", "primary_key", "unique_key", "multiple_key", "blob", "unsigned", "zerofill", "binary", "enum", "auto_increment", "timestamp".
mysql_list_fields
���������� ������ ����� �������.
��������� :
int mysql_list_fields(string dbname, string tblname [,int link_identifier])
������� mysql_list_fields() ���������� ���������� �� ��������� ������� tblname � ���� ������ bdname, ��������� ������������� ���������� link_identifier, ���� �� ����� (� ��������� ������ - ��������� �������� ����������). ������������ �������� - ������������� ����������, ������� ����� ���� ��������������� �������� ����������. � ������ ������ ������������ -1, ���� ��������� ������ ����� ���� ������� ������� ��������.
���������� ������ ����� �������.
��������� :
int mysql_list_fields(string dbname, string tblname [,int link_identifier])
������� mysql_list_fields() ���������� ���������� �� ��������� ������� tblname � ���� ������ bdname, ��������� ������������� ���������� link_identifier, ���� �� ����� (� ��������� ������ - ��������� �������� ����������). ������������ �������� - ������������� ����������, ������� ����� ���� ��������������� �������� ����������. � ������ ������ ������������ -1, ���� ��������� ������ ����� ���� ������� ������� ��������.
$link=mysql_connect($host,$user,$pass); $fields=mysql_list_fields("db1", "table", $link); $colums=mysql_num_fields($fields); // ����� ����� � ������� // ����� ����������� ����� ���� ����� ������� for($i=0;$i<$colums;$i++) { echo mysql_field_name($fields,$i)."<BR>"; }
mysql_num_fields
��� ������� ���������� ����� ����� � ����� ������ ����������, �.�. ����� ������� � ����������.
��������� :
int mysql_num_fields(int result)
� ���� ����������, ������� ��������� ���������� �������������� ����������� "���������� ������� ����������".
��� ������� ���������� ����� ����� � ����� ������ ����������, �.�. ����� ������� � ����������.
��������� :
int mysql_num_fields(int result)
� ���� ����������, ������� ��������� ���������� �������������� ����������� "���������� ������� ����������".
mysql_errno
���������� ����� ��������� ������.
��������� :
int mysql_errno ([int link_identifier])
������ ������� ���������� ����� ��������� ������������������ ������ ��� 0, ���� ������ ���.
������������� link_identifier ����� �� ���������, ���� �� ����� ������ �������� ���� ����������� ������ ���� ����������.
���������� ����� ��������� ������.
��������� :
int mysql_errno ([int link_identifier])
������ ������� ���������� ����� ��������� ������������������ ������ ��� 0, ���� ������ ���.
������������� link_identifier ����� �� ���������, ���� �� ����� ������ �������� ���� ����������� ������ ���� ����������.
mysql_connect("dbname"); echo mysql_errno().": ".mysql_error()."<BR>";
mysql_error
���������� ��������� �� ������.
��������� :
string mysql_error ([int link_identifier])
��� ������� ���������� ������, ���������� ����� ��������� �� ������ ��� ������ ������, ���� ������ ������.
���������� ��������� �� ������.
��������� :
string mysql_error ([int link_identifier])
��� ������� ���������� ������, ���������� ����� ��������� �� ������ ��� ������ ������, ���� ������ ������.
mysql_connect("dbname"); echo mysql_errno().": ".mysql_error()."<BR>";