mysqli Flashcards
What MySQL version accessibility can be accessed by mysqli?
4.1 and above.
What is the “dual interface” feature of the mysqli extension?
It supports the procedural and object-oriented programming interface.
Is there a performance difference between the mysql and mysqli extensions?
No.
Can you switch between procedural and object-oriented interfaces with mysqli?
Yes, but it’s not recommended.
Can you open a TCP/IP connection using the hostname ‘localhost’?
No, ‘localhost’ is bound to the use of Unix domain sockets. You must use 127.0.0.1 instead.
What happens when using mysqli, and a connection parameter is omitted?
mysqli will attempt to use the default values that are set in the PHP configuration file. If that doesn’t work, then it may default to the library built-in values.
What is the mysqli default host value?
A Unix socket connection on localhost. If socket is unset or empty, and a Unix socket connection is requested, then a connection to the default socket on /tmp/mysql.sock is attempted. If not, it will default to post 3306.
Can connection options be set after a network connection is established?
No.
For setting a connection option, what three steps are performed?
- Creating a connection handle with mysqli_init().
- Setting the requested options using mysqli_options().
- Establishing the network connection with mysqli_real_connect().
How does connection pooling work?
By default, mysqli uses persistent database connections, which are a special kind of pooled connection. By default, every database connection opened by a script is either explicitly closed by the user during runtime, or released automatically at the end of the script. Persistent connections, however, are put into a pool for later reuse, if a connection to the same server using the same username, password, socket, port and default database is opened.
Can a pooled connection be used by one or more scripts subsequently?
Yes.
When does mysqli open a new connection?
When an unused persistent connection for a given combination of host, username, password, socket, port, and default database can not be found in the connection pool.
What PHP directive can be used to enable and disable the use of persistent mysql connections?
myqsli.allow_persistent
How can you limit the total number of persistent mysql connections allowed by a script?
With the PHP directive mysqli.max_links.
How can you limit the maximum number of persistent mysql connections allowed by a PHP process?
With the PHP directive mysqli.max_persistent.
Are artifacts from previous usages of the same connection visible in persistent connections?
No. The persistent connection appears to the user as if it was just opened. Before a persistent connection is reused, the mysqli extension implicitly calls mysqli_change_user() to reset the state.
Calling mysqli_query() is identical to calling…
…mysqli_real_query() followed by mysqli_store_result().
mysqli_query() combines statement execution and…
…result set buffering.
When should unbuffered mysql result sets be used?
When client memory is a short resource, and freeing server resources as early as possible to keep server load low is important.
With the text protocol, the MySQL server converts all data of result sets into ______ before sending.
strings
This conversion is done regardless of the SQL result set column data type.
For integer and float columns, how can you convert them back to PHP numbers?
Set the MYSQLI_OPT_INT_AND_FLOAT_NATIVE connection option, if using mysqlnd library.
What is another name for a prepared statement?
Parameterized statement.
The MySQL server supports using anonymous, positional placeholder with…
?
What is the basic workflow of prepared statements?
- At the prepare stage, a statement template is sent to the database server. The server performs a syntax check and initializes server internal resources for later use. This only happens on the first invocation of a prepared statement.
- During the execute stage, the client binds parameter values and sends them to the server. The server creates a statement from the statement template and the bound values to execute it using the previously-created internal resources.