PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<wordwrapsybase_affected_rows>
view the version of this page
Last updated: Sat, 19 Apr 2003

C. Sybase functions

Einf�hrung

Anforderungen

Installation

To enable Sybase-DB support configure PHP --with-sybase[=DIR]. DIR is the Sybase home directory, defaults to /home/sybase. To enable Sybase-CT support configure PHP --with-sybase-ct[=DIR]. DIR is the Sybase home directory, defaults to /home/sybase.

Laufzeit Konfiguration

Das Verhalten dieser Funktionen wird von Einstellungen in der php.ini bestimmt.

Tabelle 1. Sybase configuration options

NameDefaultChangeable
sybase.allow_persistent"On"PHP_INI_SYSTEM
sybase.max_persistent"-1"PHP_INI_SYSTEM
sybase.max_links"-1"PHP_INI_SYSTEM
sybase.interface_file "/usr/sybase/interfaces"PHP_INI_SYSTEM
sybase.min_error_severity"10"PHP_INI_ALL
sybase.min_message_severity"10"PHP_INI_ALL
sybase.compatability_mode"Off"PHP_INI_SYSTEM
magic_quotes_sybase"Off"PHP_INI_ALL

Here is a short explanation of the configuration directives.

sybase.allow_persistent boolean

Whether to allow persistent Sybase connections.

sybase.max_persistent integer

The maximum number of persistent Sybase connections per process. -1 means no limit.

sybase.max_links integer

The maximum number of Sybase connections per process, including persistent connections. -1 means no limit.

sybase.min_error_severity integer

Minimum error severity to display.

sybase.min_message_severity integer

Minimum message severity to display.

sybase.compatability_mode boolean

Compatability mode with old versions of PHP 3.0. If on, this will cause PHP to automatically assign types to results according to their Sybase type, instead of treating them all as strings. This compatability mode will probably not stay around forever, so try applying whatever necessary changes to your code, and turn it off.

magic_quotes_sybase boolean

If magic_quotes_sybase is on, a single-quote is escaped with a single-quote instead of a backslash if magic_quotes_gpc or magic_quotes_runtime are enabled.

Anmerkung: Note that when magic_quotes_sybase is ON it completely overrides magic_quotes_gpc . In this case even when magic_quotes_gpc is enabled neither double quotes, backslashes or NUL's will be escaped.

Tabelle 2. Sybase-CT configuration options

NameDefaultChangeable
sybct.allow_persistent"On"PHP_INI_SYSTEM
sybct.max_persistent"-1"PHP_INI_SYSTEM
sybct.max_links"-1"PHP_INI_SYSTEM
sybct.min_server_severity"10"PHP_INI_ALL
sybct.min_client_severity"10"PHP_INI_ALL
sybct.hostnameNULLPHP_INI_ALL
sybct.deadlock_retry_count"-1"PHP_INI_ALL

Here is a short explanation of the configuration directives.

sybct.allow_persistent boolean

Whether to allow persistent Sybase-CT connections. The default is on.

sybct.max_persistent integer

The maximum number of persistent Sybase-CT connections per process. The default is -1 meaning unlimited.

sybct.max_links integer

The maximum number of Sybase-CT connections per process, including persistent connections. The default is -1 meaning unlimited.

sybct.min_server_severity integer

Server messages with severity greater than or equal to sybct.min_server_severity will be reported as warnings. This value can also be set from a script by calling sybase_min_server_severity(). The default is 10 which reports errors of information severity or greater.

sybct.min_client_severity integer

Client library messages with severity greater than or equal to sybct.min_client_severity will be reported as warnings. This value can also be set from a script by calling sybase_min_client_severity(). The default is 10 which effectively disables reporting.

sybct.hostname string

The name of the host you claim to be connecting from, for display by sp_who. The default is none.

sybct.deadlock_retry_count int

Allows you to to define how often deadlocks are to be retried. The default is -1, or "forever".

For further details and definition of the PHP_INI_* constants see ini_set().

Resource Typen

Vordefinierte Konstanten

Diese Erweiterung definiert keine Konstanten.

Inhaltsverzeichnis
sybase_affected_rows -- get number of affected rows in last query
sybase_close -- close Sybase connection
sybase_connect -- open Sybase server connection
sybase_data_seek -- move internal row pointer
sybase_deadlock_retry_count -- set the deadlock retry count
sybase_fetch_array -- fetch row as array
sybase_fetch_assoc -- fetch row as associative array
sybase_fetch_field -- get field information
sybase_fetch_object -- fetch row as object
sybase_fetch_row -- get row as enumerated array
sybase_field_seek -- set field offset
sybase_free_result -- free result memory
sybase_get_last_message -- Returns the last message from the server
sybase_min_client_severity -- Sets minimum client severity
sybase_min_error_severity -- Sets minimum error severity
sybase_min_message_severity -- Sets minimum message severity
sybase_min_server_severity -- Sets minimum server severity
sybase_num_fields -- get number of fields in result
sybase_num_rows -- Get number of rows in result
sybase_pconnect -- open persistent Sybase connection
sybase_query -- Send Sybase query
sybase_result -- get result data
sybase_select_db -- select Sybase database
sybase_set_message_handler -- set handler called when a server message is raised
sybase_unbuffered_query -- send Sybase query and do not block


User Contributed Notes
Sybase functions
add a note
Xtof at fromages-et-desserts dot com
20-Feb-2000 05:18

To store an image file into Sybase try this :

$data = bin2hex(fread(fopen($image,"r"), filesize($image)));
//don't forget the 0x before the hex data.
if(! sybase_query("INSERT INTO test_image (image) VALUES (0x".$data.")")) die ("Unable to store the image.");

To retrieve it just do a select and use a hex2bin function (this one has been submitted by [email protected] and is the fastest) :

function hex2bin($data) {
    $len = strlen($data);
     return pack("H" . $len, $data);
}

PS : use CT-lib rather than DB-lib (Sybase doesn't work on it anymore!)

tcurdt at dff dot st
01-Mar-2000 08:34

Poor documentation on sybase support!! Here's how I made it work... First get the linux ASE from sybase (maybe the ctlibs provided at php.net will do fine, too) Install the ASE rpm. (some distributions don't have system libs etc in the rpm database so you might get some dependency errors. If your systems fits the requirements install with "ignore dependencies") Recompile php with option --with-sybase-ct=/dirtoyoursybasehome. Then you need to set the env variable for (at least)your apache user by export SYBASE=/dirtoyoursybasehome. Now you need to set up your servers (like DSNs for ODBC). Edit the file $SYBASE/interfaces and add your server entries:

SERVERNAME
 query tcp ether 172.16.1.4 4100
master tcp ether 172.16.1.4 4100

(change IP/FQHN and port to your setup) Now you can check your config by using
$SYBASE/bin/isql -S SERVERNAME -U DBUSER -P PASSWD
If you get a prompt you have connected to your sybase! Hurray! Now you can try with php
$db=sybase_connect("SERVERNAME","DBUSER","DBPASSWD");
And... Voila!

ericnewman at aol dot com
06-Mar-2000 08:57

I struggled to get this to work for a week. Here's a tip. Log on to your system using the same login as your web server, probably "nobody". Using this account, make sure you can get isql to work. In my case, I had to change the permissions on the /opt/sybase folder, as well as chmod the /opt/sybase/interfaces file to 644. (It was 600 by default, and did not allow anyone but root to read it.) Once I did this, things started to happen...
james at lasolas dot com
22-Mar-2000 01:28

If you get a segfault with sybase-ct, add a en_US entry to your $SYBASE/locales/locales.dat file:
<PRE>
[linux]
locale = en_US, us_english, iso_1
...
</PRE>

ilya at vtrails dot com
09-Jul-2000 02:03

Amigos, pay attention: sybase_get_last_message() is gone! Read logs or set track_errors=On and use $php_errormsg instead.
hoadley at xoom dot com
18-Aug-2000 09:41

I would STRONGLY recommend using the ct library over the db library when compiling sybase support with php4+. I ran into strange http child seg faults when trying to issue multiple sql statements in one php page. Using ct-library there is no problem.
chptma at hydra dot esfm dot ipn dot mx
06-Sep-2000 08:13

about sybase-ct library

You can download the file from php.net but the samples in the tar (and php) maybe not compile I have this problem in some systems (but not in others with old librarys and old gcc).

Try freetds from www.freetds.org that is ok!

System wthout trouble
Debian 2.1 gcc (2.7.2.3) libc-2.0.7.so
System With trouble
Debian 2.2 gcc (2.95.2) libc-2.1.3.so
RedHat 6.2 gcc [egcs] (2.91.66) libc-2.1.3.so

Please refer to mssql if you try to connect to MS SQL Server!!!

wylie at storerunner dot net
28-Sep-2000 04:12

The best place to get Sybase's RPMs:


koos at kzdoos dot xs4all dot nl
09-Oct-2000 06:20

A bit more about blobs:


If you want to retrieve blobs without them getting truncated, do a 'set textsize value' query first.

heumann at s-und-i dot com
13-Oct-2000 08:17

This should make the image/blob subject rather complete:
PHP 3 seems to have a bug with image columns in sybase. Apache gets a segmentation fault when trying to retrieve an image column with more than a certain amount of characters (even when using set textsize).
The work around is to use text columns instead. They have the same capacity, only you need to convert the data to ASCII (e.g. Hex, see examples in earlier contributions, bin2hex). Remember to put the data in quotes, too, when INSERTing.

Jarkko dot Isokungas at finebyte dot com
04-Dec-2000 08:03

After weeks of work, I have succeeded in getting PHP4 to talk with ASA 7.0 on Redhat Linux 7.0.

Here's my very incomplete not so beautiful FAQ.



Let me know if this helps you.

tysonlt2webmedia.com.au
25-May-2001 04:27

**** NEWS FLASH ****

ATTENTION ALL STRUGGLING TO SETUP SYBASE!

There is finally a complete howto on Sybase/Apache/PHP/Linux here:



Hope it helps.

tysonlt2webmedia.com.au
08-Jun-2001 08:40

******* ANOTHER NEWS FLASH :) *******
Hi, the Apache-PHP-Sybase mini howto is now available at
Enjoy.

borreo at softhome dot net
28-Jun-2001 01:33

It's important to note that sybase_ct connect or pconnect were causing GPF.
If you experienced this problem, just update PHP to 4.0.6.

mad at dactar dot ch
04-Jul-2001 08:16

The best place to get Sybase for Debian :


rbuico at ntep dot nec dot co dot jp
28-Aug-2001 03:54

maybe it can help.
my database is ASE

this is my script....

<?
$cnn = sybase_connect("db_server","sa","password");
$result = sybase_query("Select itemno,stockno from your_db..your_table");
$i = 0;
while ($r = sybase_fetch_array($result)) {
$i++;
$itemno = $r["itemno"];
$stockno = $r["stockno"];
echo "$i    $stockno   $itemno
";
}
?>

note that I did not use the
sybase_select_db("db") function because ASE had a default database.
thx...

borreo at softhome dot net
14-Sep-2001 06:22

If you use IIS and sybase-ct library, be sure to use PHP 4.0.6 or higher, since older version caused crashes.
borreo at softhome dot net
14-Sep-2001 06:29

If you have a Linux machine with Sybase ASE 11.9.2, Php 4.0.6, Apache and Sybase-ct library, don't upgrade to Sybase ASE 12.5 yet, or Apache will stop working.
Since 12.5 is newer than 4.0.6, I guess this will be fixed soon.

basilio_mail at chat dot ru
25-Oct-2001 10:56

For those, who might want to use SyBase client not only under Linux, you may try to use open-source FreeTDS library -

Also there's how-to for FreeTDS and PHP:

rudolf at 1stomni dot com
27-Feb-2002 07:44

PhpSybaseAdmin

elee at kinwai dot net
15-Apr-2002 09:28

Freetds 5.2 bugs!!

For those who use Freetds 5.2 running under linux connect to sqlserver2000, there is a bugs in selecting NVARCHAR field that data will either duplicated or truncated. To avoid this problem, please use CAST or CONVERT function in sql statement such as:
$query="select CAST(fieldname as nchar(1000)) as fieldname from table"

Feel free to contact us at
[email protected]
or
[email protected]

German Chu & Eagle Lee

ddc at portalframework.com
14-May-2002 06:19

Compiling PHP with Sybase ASE 12.5 on Linux.

Assuming that you have installed the Sybase ASE 12.5 client in linux, and you have the SYBASE env variable set, you can compile PHP >= 4.0.6 with Sybase ASE 12.5.
Just use:

 --with-sybase-ct=$SYBASE/OCS
instead of
--with-sybase-ct=$SYBASE

AnatolyKoval at hotmail dot com
17-Jun-2002 10:25

The way to use Sybase Adaptive Server Anywhere+PHP+Apache on Unix
dmitry at viewtrade dot com
13-Aug-2002 09:44

If you compile php with freetds (www.freetds.org) support (--with-sybase in php), apache might NOT START due to unresolved symbol.

This can be easily solved by adding -ltds flag in config_vars.mk file after configuring PHP under the line EXTRA_LIBS.

You can view this debug fix on www.freetds.org under FAQ section.

aj at bootsector dot org
04-Sep-2002 09:10

A note for all who may be struggling...  Microsoft did away with the ct-lib support in SQL Server 2000.

I played with it and found a couple of articles related to it on google.  A workaround/different method would be preferrable.  Anybody?

ddc at portalframework dot com
07-Oct-2002 01:05

If you would like to use the wide table support of Sybase ASE 12.5, take advantage of XML/XQL embedded in the database and use varchars of more than 255 char, you'll need to recompile PHP changing this line in the
 php_sybase_ct.h file:

From:

#define CTLIB_VERSION CS_VERSION_100

To:

#define CTLIB_VERSION CS_VERSION_125

This will only run if you have installed Sybase ASE Open Client v. 12.5 and configured PHP telling it where the OCS is... (./configure --with-sybase-ct=$SYBASE_HOME/OCS [...])

--
Diego Dal Cero.

add a note

<wordwrapsybase_affected_rows>
 Last updated: Sat, 19 Apr 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Wed May 14 01:12:44 2003 CEST