English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função mysqli_field_tell() retorna a posição do ponteiro do campo.
Um objeto de resultado PHP (classe mysqli_result) representa o resultado MySQL retornado por consultas SELECT, DESCRIBE ou EXPLAIN. O cursor do campo do objeto de resultado/O ponteiro aponta para o campo correspondente (valor da coluna).
mysqli_field_tell()A função aceita um objeto de resultado como parâmetro, pesquisa e retorna a posição atual do ponteiro do campo no objeto fornecido.
mysqli_field_tell($result);
Serial number | Parameters and descriptions |
---|---|
1 | result(必需) This is the identifier representing the result object. |
The PHP mysqli_field_tell() function returns an integer value that specifies the position of the field pointer in the given result object.
This function was originally in PHP version5introduced and can be used in all higher versions.
The following example demonstratesmysqli_field_tell()Usage of the function (procedural style), get all field information, and then output the field name, table name, and data type by mysqli_field_tell():
<?php mysqli_query($con, \255), Last_Name VARCHAR(255), Place_Of_Birth VARCHAR(255), Country VARCHAR(255))"); print("Criar tabela.....\n"); mysqli_query($con, \1, 'Sikhar', 'Dhawan', 'Delhi', 'India')"); mysqli_query($con, \2 mysqli_query($con, \3, 'Kumara', 'Sangakkara', 'Matale', 'Srilanka')"); print("Inserting records..... "); //retrieve the content of the table $res = mysqli_query($con, \ * FROM myplayers"); //get field while($info = mysqli_fetch_field($res)){ //current field $currentfield = mysqli_field_tell($res); print("Current Field: ".$currentfield. "); print("Name: ".$info-> nome. "); print("Table: ".$info-> table. "); print("Type: ".$info->type." "); } //Terminar instrução mysqli_free_result($res); //Fechar conexão mysqli_close($con); ?>
Resultados de saída
Criar tabela..... Inserir registro..... Campo Atual: 1 Nome: ID Tabela: myplayers Tipo: 3 Campo Atual: 2 Nome: Nome Tabela: myplayers Tipo: 253 Campo Atual: 3 Nome: Sobrenome Tabela: myplayers Tipo: 253 Campo Atual: 4 Nome: Local_de_Nascimento Tabela: myplayers Tipo: 253 Campo Atual: 5 Nome: País Tabela: myplayers Tipo: 253
Na sintaxe da função orientada a objetos, é$result-> current_field;.A seguir está um exemplo de como essa função obtém o campo atual e retorna o nome do campo no estilo orientado a objetos;
<?php //Conectar $con = new mysqli("localhost", "root", "password", "mydb"); $con -> query("CREATE TABLE Test(Name VARCHAR(255), ID INT); $con -> query("insert into Test values('Raju', 25),('Rahman', 30),('Sarmista', 27); print("Criar tabela.....\n"); $stmt = $con -> prepare("SELECT * FROM Test WHERE Name in(?, ?) $stmt -> bind_param("ss", $name1, $name2); $name1 = 'Raju'; $name2 = 'Rahman'; //Executar instrução $stmt->execute(); //Resultados de busca $result = $stmt->get_result(); //Campo Atual $info = $result->fetch_field(); $field = $result->current_field; print("Campo Atual: ").$field." "; print("Nome do Campo: ").$info->name); //Terminar instrução $stmt->close(); //Fechar conexão $con->close(); ?>
Resultados de saída
Criar tabela..... Campo Atual: 1 Nome do Campo: Nome