skip to Main Content

I’m using PHP to connect to a SQL Anywhere 17 database.
One of two commands can be used to close the connection.
sasql_disconnect or sasql_close.

At https://infocenter.sybase.com/help/index.jsp I can find very brief information that:
sasql_disconnect: Closes a connection that has been opened with sasql_connect or sasql_pconnect.
sasql_close: Closes a previously opened database connection.

Both functions take the same type of parameters and return true or false.

There is no information on the above page about the differences between the two functions.
There is also no information that the reason for the existence of one of them was the desire to maintain compatibility with previous versions of the database.

Still, I suspect there is a reason for the existence of the two functions.
Does anyone know how they differ? When to use one and when the other?
Thank you.
Marcin.

2

Answers


  1. sasql_disconnect and sasql_close are functions used to manage database connections. While they serve similar purposes, there are some differences between them:

    sasql_disconnect: This function is used to terminate the connection to a database. When you call sasql_disconnect, it will close the connection established with the database server and release any associated resources. It essentially ends the session with the database, and you cannot execute any further SQL statements until you establish a new connection.

    sasql_close: This function is used to close a specific cursor or result set that you have obtained from executing a SQL query. In SAS, when you execute a SQL query using sasql_exec_direct or sasql_prepare, you usually retrieve the results into a cursor. After you have finished working with the result set, you need to close the cursor using sasql_close to release the resources associated with it.

    To summarize, sasql_disconnect is used to terminate the entire database connection, while sasql_close is used to close a specific cursor or result set within an active connection.

    Login or Signup to reply.
  2. My assumption is that they are identical, and there is no functional difference between them.

    The verb "disconnect" seems to be the canonical one, i.e. the one normally used. When looking at implementations in other languages, those examples exclusively use disconnect. For example, their Ruby library.

    Meanwhile, PHP mostly uses the "close" verb. At least in both mysqli_close() and pg_close(). So it makes sense to follow the same convention when writing a PHP library, as it will be the function name most developers would expect.

    Because of these conflicting standards, having aliases for functions would make sense. Especially in a language like PHP, which has many function aliases already.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search