Query: odbc_connect
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ODBC_CONNECT(3) 1 ODBC_CONNECT(3) odbc_connect - Connect to a datasourceSYNOPSISresource odbc_connect (string $dsn, string $user, string $password, [int $cursor_type])DESCRIPTIONThe connection id returned by this functions is needed by other ODBC functions. You can have multiple connections open at once as long as they either use different db or different credentials. With some ODBC drivers, executing a complex stored procedure may fail with an error similar to: "Cannot open a cursor on a stored proce- dure that has anything other than a single select statement in it". Using SQL_CUR_USE_ODBC may avoid that error. Also, some drivers don't support the optional row_number parameter in odbc_fetch_row(3). SQL_CUR_USE_ODBC might help in that case, too.PARAMETERSo $dsn - The database source name for the connection. Alternatively, a DSN-less connection string can be used. o $user - The username. o $password - The password. o $cursor_type - This sets the type of cursor to be used for this connection. This parameter is not normally needed, but can be useful for work- ing around problems with some ODBC drivers. The following constants are defined for cursortype: o SQL_CUR_USE_IF_NEEDED o SQL_CUR_USE_ODBC o SQL_CUR_USE_DRIVERRETURN VALUESReturns an ODBC connection or ( FALSE) on error.EXAMPLESExample #1 DSN-less connections <?php // Microsoft SQL Server using the SQL Native Client 10.0 ODBC Driver - allows connection to SQL 7, 2000, 2005 and 2008 $connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password); // Microsoft Access $connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password); // Microsoft Excel $excelFile = realpath('C:/ExcelData.xls'); $excelDir = dirname($excelFile); $connection = odbc_connect("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir" , '', ''); ?>SEE ALSOFor persistent connections: odbc_pconnect(3). PHP Documentation Group ODBC_CONNECT(3)
Similar Topics in the Unix Linux Community |
---|
remote sybase connection and php error. |
converting xls,xlsx files ?? |
Execute multiple SQL scripts from single SQL Plus connection |
awk and leading zeroes |
Cut command not working in for loop |