72.0k views
3 votes
Which of the following PHP function calls sends an SQL statement to a database and returns the records that satisfy the statement?

a) mysqli_query()
b) sql_fetch()
c) pdo_execute()
d) mysql_select()

User Zzart
by
8.4k points

1 Answer

0 votes

Final answer:

The PHP function that sends an SQL statement to a database and retrieves the records is mysqli_query(). It is used primarily with MySQL and takes a connection identifier and SQL query string as arguments.

Step-by-step explanation:

The PHP function that is used to send an SQL statement to a database and fetch the records that satisfy the statement is mysqli_query(). When used with MySQL, this function takes two arguments, a connection identifier and the SQL query string. Once called, it sends the query to the database server associated with the given connection identifier and retrieves the matching records.

For example, a call to this function might look something like:

$connection = mysqli_connect("localhost", "username", "password", "database");
$query = "SELECT * FROM tablename WHERE condition";
$result = mysqli_query($connection, $query);

After executing the query, mysqli_query() returns the result set, which can then be used to fetch data with functions like mysqli_fetch_assoc(), mysqli_fetch_array(), or mysqli_fetch_row().

User BCran
by
7.3k points