|
When used, the macro creates a new connection with the information inserted in its parameters. This connection is available throughout the current session Scriptcase and ceases to exist when the session is closed.
The new connection will only be available in the next application.
1º Parameter: Connection name.
Note: If there is a connection created within the Scriptcase with the same name, this macro has no effect. Connections created within the Scriptcase prevail. If you want to edit an existing connection, see the documentation for the macro sc_connection_edit.
2º Parameter: Array of items containing the connection information. Check out the indices of the array:
Indice
|
Description |
Example |
| ['drive'] |
Driver of the database used for the connection (see table below) |
$arr_conn['drive'] = "oci8" |
| ['server'] |
Database server (host) |
$arr_conn['server'] = "127.0.0.1" |
| ['user'] |
Database username |
$arr_conn['user'] = "root" |
| ['password'] |
Database password |
$arr_conn['password'] = "secretpass123" |
| ['database'] |
Database name used in the connection |
$arr_conn['database'] = "sc_samples" |
| ['persistent'] |
Defines if the connection is persistent or not |
$arr_conn['persistent'] = "Y" / "N" |
| ['encoding'] |
Configure the connection encoding |
$arr_conn['encoding'] = "utf8" |
Note: It is required that all items are filled, with the exception of items ['persistent'] and ['encoding'].
See below the driver's list:
Driver
|
Description
|
| access |
MS Access |
| ado_access |
MS Access ADO |
| odbc |
ODBC Generic |
| db2 |
DB2 |
| db2_odbc |
DB2 ODBC Native |
| odbc_db2 |
DB2 ODBC Generic |
| odbc_db2v6 |
DB2 ODBC Genérico 6 or less |
| pdo_db2_odbc |
DB2 PDO ODBC |
| pdo_ibm |
DB2 PDO |
| firebird |
Firebird |
| pdo_firebird |
Firebird PDO |
| borland_ibase |
Interbase 6.5 or more |
| ibase |
Interbase |
| pdo_informix |
Informix PDO |
| informix |
Informix |
| informix72 |
Informix 7.2 or less |
| ado_mssql |
MSSQL Server ADO |
| pdo_sqlsrv |
MSSQL Server NATIVE SRV PDO |
| mssqlnative |
MSSQL Server NATIVE SRV |
| odbc_mssql |
MSSQL Server ODBC |
| mssql |
MSSQL Server |
| pdo_dblib |
DBLIB |
| pdo_mysql |
MySQL PDO |
| mysqlt |
Mysql (Transactional) |
| mysql |
MySQL (Non-Transactional) |
| pdo_oracle |
Oracle PDO |
| oci805 |
Oracle 8.0.5 or more |
| odbc_oracle |
Oracle ODBC |
| oci8 |
Oracle 8 |
| oci8po |
Oracle 8 Portable |
| oracle |
Oracle 7 or less |
| postgres7 |
PostgreSQL 7 ou Acima |
| pdo_pgsql |
PostgreSQL PDO |
| postgres64 |
PostgreSQL 6.4 or more |
| postgres |
PostgreSQL 6.3 or more |
| pdosqlite |
SQLite PDO |
| sqlite |
SQLite |
| sybase |
Sybase |
| pdo_sybase_dblib |
Sybase PDO DBLIB |
| pdo_sybase_odbc |
Sybase PDO ODBC |
Example:
$arr_conn = array();
$arr_conn['drive'] = "mysqlt"; $arr_conn['server'] = "127.0.0.1"; $arr_conn['user'] = "root"; $arr_conn['password'] = "pass123"; $arr_conn['database'] = "sc_samples"; $arr_conn['persistent'] = "Y"; $arr_conn['encoding'] = "utf8";
sc_connection_new("new_conn_mysql", $arr_conn);
|