PHP SQLite3 doğru kullanımı

1 Cevap php

Arasındaki fark nedir:

$db = new SQLiteDatabase('name.db');

ve

$db = new PDO('sqlite:name.db');

Since, I don't understve the big picture here, details are premature for me ve the information available online appears to assume certain knowledge I seem to be lacking. Please don't just paste in links to the PHP manual. Less specific, more general concepts will be useful for me.

SQLite 2 aksine Ayrıca, bu yaklaşımların her ikisi de, SQLite 3 kullanabilirim?

1 Cevap

Doğrudan SQLite işlevleri / sınıfları kullanarak, PHP kod yalnızca SQLite ile uyumlu olacaktır.

Using PDO, your PHP code will be compatible with many database systems -- see PDO Drivers for a list of existing drivers.
Quoting the Introduction page of PDO :

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data.


This abstraction layer can be useful if you want your code to be compatible with more than one DB engine ; but note that :

  • PDO kullanarak, her zaman bir veritabanı sistemine özgü özellikleri kullanamazsınız
  • PDO kullanarak PHP kodu uyumlu olacağı anlamına gelir; o SQL çok olacak anlamına gelmez: hala sizin işiniz.


For the question about SQLite and SQLite3 :

  • PDO seems to support both -- see SQLite Functions (PDO_SQLITE)
    • Birini veya başka kullanmak için, sadece farklı DSN kullanmak olmalıdır.
    • Not: birkaç farklı DB sistemleri ile çalışan PDO büyük olduğu için bir şey türüdür ;-)
  • Using the specific DB extensions :
    • SQLite2 için bir uzantısı vardır: SQLite
    • And one other extension for SQLite3 : SQLite3
      • Bu bir tek PHP> = 5.3 ile birlikte gibi görünüyor unutmayın