PHP MySQLi Query


 

PHP MySQLi Query

In the current tutorial we will study how to make query in mysqli, the example will make the concept more clear.

In the current tutorial we will study how to make query in mysqli, the example will make the concept more clear.

mysqli::query

It performs a query in specified database, the format is as follows:

Object Oriented Style:

mixed mysqli::query ( string $query [, int $resultmode ] )

Procedural Style:

mixed mysqli_query ( mysqli $link , string $query [, int $resultmode ] )

There are three parameters are present in it, link, query and resultmode.

In the example below though it is similar to previous example, but to maintain the ease of understand we put the same example.

Example:

<?php

$db=new mysqli("localhost","root","","rose");

if(mysqli_connect_error())

{

printf("Connection failed:%s \n",mysqli_connect_error());

exit();

}

$result=$db->query("select name from student");

printf("Affected rows:%d \n",$db->affected_rows);

Output:

Affected rows :- 1

Ads