downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDOStatement> <PDO::rollBack
[edit] Last updated: Fri, 23 Mar 2012

view this page in

PDO::setAttribute

(PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)

PDO::setAttributeBir öznitelik tanımlar

Açıklama

bool PDO::setAttribute ( int $öznitelik , mixed $değer )

Veritabanı için bir öznitelik tanımlar. Bazı temel öznitelikler aşağıda listelenmiştir. Bazı sürücülerin kendilerine özgü öznitelikleri olabilir.

  • PDO::ATTR_CASE: Sütun isimlerinin harflerini belli bir büyüklüğe zorlar.

    • PDO::CASE_LOWER: Sütun isimlerinin harflerini küçük harfe zorlar.

    • PDO::CASE_NATURAL: Sütun isimlerinin harfleri veritabanı sürücüsünden döndüğü haliyle kullanılır.

    • PDO::CASE_UPPER: Sütun isimlerinin harflerini büyük harfe zorlar.

  • PDO::ATTR_ERRMODE: Hata raporlama.

    • PDO::ERRMODE_SILENT: Sadece hata kodlarını atar.

    • PDO::ERRMODE_WARNING: Bir E_WARNING çıktılanır.

    • PDO::ERRMODE_EXCEPTION: Bir istisna oluşur.

  • PDO::ATTR_ORACLE_NULLS (Sadece Oracle için değil, bütün sürücüler için kullanılabilir): NULL'a ve boş dizgelere dönüşüm.

    • PDO::NULL_NATURAL: Dönüşüm yok.

    • PDO::NULL_EMPTY_STRING: Boş dizge NULL'a dönüştürülür.

    • PDO::NULL_TO_STRING: NULL boş dizgeye dönüştürülür.

  • PDO::ATTR_STRINGIFY_FETCHES: Döndürülürken sayısal değerler dizgeye dönüştürülür. Mantıksal bir değer gerekir.

  • PDO::ATTR_STATEMENT_CLASS: PDOStatement sınıfından türetilmiş kullanıcı tanımlı bir deyim sınıfı tanımlar. Kalıcı PDO bağlantılarıyla kullanılamaz. array(string sınıfadı, array(mixed kurucu_değiştirgeler)) gerekir.

  • PDO::ATTR_AUTOCOMMIT (OCI, Firebird ve MySQL'de kullanılır): Her tek deyimin özdevinimli gönderilip gönderilmeyeceği belirtilir.

  • PDO::MYSQL_ATTR_USE_BUFFERED_QUERY (MySQL'de kullanılır): Tamponlu sorgular kullanılır.

Dönen Değerler

Başarı durumunda TRUE, başarısızlık durumunda FALSE döner.



PDOStatement> <PDO::rollBack
[edit] Last updated: Fri, 23 Mar 2012
 
add a note add a note User Contributed Notes PDO::setAttribute
antoyo 11-Jan-2011 05:49
There is also a way to specifie the default fetch mode :
<?php
$connection
= new PDO($connection_string);
$connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
?>
jas at dansupport dot dk 17-Nov-2008 01:24
Calling this function with PDO::MYSQL_ATTR_USE_BUFFERED_QUERY will seem to work, but it DOES NOT.
Instead, set it in the options array when instantiating the PDO connection.

Example:
<?php
$con
= new PDO("mysql:dbname=dbname;host=some.ip", "user", "pass", array(
     
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
   ));
?>
colinganderson [at] gmail [dot] com 18-May-2007 07:59
Because no examples are provided, and to alleviate any confusion as a result, the setAttribute() method is invoked like so:

setAttribute(ATTRIBUTE, OPTION);

So, if I wanted to ensure that the column names returned from a query were returned in the case the database driver returned them (rather than having them returned in all upper case [as is the default on some of the PDO extensions]), I would do the following:

<?php
// Create a new database connection.
$dbConnection = new PDO($dsn, $user, $pass);

// Set the case in which to return column_names.
$dbConnection->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
?>

Hope this helps some of you who learn by example (as is the case with me).

.Colin
gregory dot szorc at gmail dot com 14-Feb-2007 08:32
It is worth noting that not all attributes may be settable via setAttribute().  For example, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE is only settable in PDO::__construct().  You must pass PDO::MYSQL_ATTR_MAX_BUFFER_SIZE as part of the optional 4th parameter to the constructor.  This is detailed in http://bugs.php.net/bug.php?id=38015
Tobi 20-Nov-2006 03:11
Hint: setting the PDO::ATTR_ERRMODE attribute to PDO::ERRMODE_EXCEPTION
worked for me only with Mysql 4.x - I took me some time to figure this out ;-)
m dot leuffen at gmx dot de 25-Jul-2006 06:44
Hi,

if you are wondering about a size-bound (1 MB) on blob and text fields after upgrading to PHP5.1.4. You might try to increase this limit by using the setAttribute() method.

This will fail. Instead use the options array when instantiating the pdo:

$pdo = new PDO ("connection_settings", "user", "pass", array
(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50));

This should fix the problem and increase the limit to 50 MB.

Bye,
  Matthias

 
show source | credits | stats | sitemap | contact | advertising | mirror sites