Mastering MySQL 4 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Mastering MySQL 4 [Electronic resources] - نسخه متنی

Ian Gilfillan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







DBI Methods Common to All Handles

The following methods are available to database handles, statement handles, and driver handles. They are mostly used for error handling.


err


$rv  = $h->err;

Returns the native error code from the last method (usually an integer).



errstr


$error_string = $dbh->errstr;

Returns an error string from the failure of the previous call.

For example:

my $hostname = 'localhost';
my $database = 'firstdb';
my $username = 'guru2b';
my $password = 'g00r002b';
#Connect to the database
my $dbh = DBI->connect("dbi:mysql:$database:$hostname", $username,–
$password) or die $DBI::errstr;



func


$h->func(@func_arguments, $func_name);

Used to call other nonstandard driver methods. This takes an array of arguments and the method name as arguments.

This does not trigger the usual error detection mechanisms (such as RaiseError or PrintError) or clear a previous error (such as $DBI::err or $DBI::errstr).



set_err


$rv = $h->set_err($err, $errstr [, $state, $method [, $rv]]);

A new method mainly used by DBI drivers and subclasses. It sets the err, errstr, and state values for the handle (to enable error handling through RaiseError and so on).

$method sets a more useful method name for the error string, and $rv sets a return value (usually undef).

For example:

sub doodle {
# … try to 'doodle'
or return $sth->set_err(1234, "Nope. Sorry. Out of luck. It all–
went wrong", undef, "doodle");
}



state


$rv  = $h->state;

Returns an error code in SQLSTATE format. Usually returns the general S1000 code when the driver does not support SQLSTATE.



trace


trace($trace_level [, $trace_filename])

See the earlier trace method.



trace_msg


$h->trace_msg($message_text [, $minimum_level]);

If tracing is enabled, outputs the message text to the trace file. If the minimum level is set (default 1), this only outputs the message if the trace level is at least that level.



/ 229