PHP Velho Oeste 2024

sybase_connect

(PHP 4, PHP 5)

sybase_connectAbre uma conexão Sybase

Descrição

sybase_connect ([ string $servername [, string $username [, string $password [, string $charset [, string $appname ]]]]] ) : resource

Retorna: um identificador de recurso Sybase positivo em caso de sucesso ou um FALSE em caso de falha.

sybase_connect() estabelece uma conexão com um servidor Sybase. O argumento servername tem que ser um nome de servidor que é definido no arquivo 'interfaces'.

Se uma segunda chamada é feita ao sybase_connect() com os mesmos argumentos nenhum novo recurso será estabelecido. Ao invés disto, o identificador de recurso do recurso já aberto será retornado.

O recurso com o servidor será fechado tão logo a execução do script termine, a não ser que ele seja fechado anteriormente ao se chamar explicitamente o sybase_close().

Exemplo #1 Exemplo sybase_connect()

<?php
    $link 
sybase_connect('SYBASE''''')
            or die(
"Could not connect !");
    print (
"Connected successfully");
    
sybase_close($link);
?>

Veja também sybase_pconnect() e sybase_close().

add a note add a note

User Contributed Notes 4 notes

up
1
naguiwerian at netscape dot net
22 years ago
To connect from win32 to Sybase on Unix , you can use sybase open client and make sure to use the hostname in sybase_connect as it is defined in the OC sql.ini file .. it worked that way !
up
0
gregory at bnl dot gov
24 years ago
If you are having trouble connecting to your sybase database on unix, try checking that the SYBASE environmental variable is set correctly. I was getting connection errors until I found out that this variable had not been set through the server.
up
-1
bkw at weisshuhn dot de
24 years ago
To decrease the level of messages sent back from the dbserver (such as 'changed context...') try:

     sybase_min_server_severity(11);
up
-4
brunello95 at aol dot com
19 years ago
freetds is a great, free tool to access your sybase tables with PHP. The setup can be a bit tricky. Use the following to put the environment variables that you need:
<?php
putenv
("SYBASE=/usr/local/freetds");
putenv ("SYBPLATFORM=linux");
putenv ("LD_LIBRARY_PATH=/usr/local/freetds/lib");
putenv ("LC_ALL=default");
putenv ('PATH=\"/usr/local/freetds/bin:$PATH\"');
putenv ("DSQUERY=SYBASE");
?>
Even if not using freetds, you'll need those env vars to make any sybase connection work. Another option is to just load them into your box from the command line.
To Top