Üç ek işlevler ezSQL_mysql sınıf eklenir:
In /libs/extensions/ezSQL/mysql/ez_sql_mysql.php... / Libs / uzantıları / / mysql / ez_sql_mysql.php ezSQL In ...
The first checks if a table exists and returns true or false. İlk kontroller bir tablo varsa ve doğru veya yanlış döndürür. Call the function like this: Bu gibi işlev arayın:
PHP Code: PHP Kodu:
if( $h -> db -> table_exists ( 'tablename' )) { ... do something ... }
The second checks if a table is empty, ie it exists but has no rows. İkinci çekleri bir tablo boş, varsa ancak satır var yani. It returns true of empty or false otherwise. Boş veya yanlış başka gerçek döndürür. You can check if a table is empty like this: Tablo böyle boş olup olmadığını kontrol edebilirsiniz:
PHP Code: PHP Kodu:
if( $h -> db -> table_empty ( 'tablename' )) { ... do something ... }
The third function checks if a column exists and returns true or false. Üçüncü Foksiyon bir sütun varsa ve doğru veya yanlış döndürür. Call the function like this: Bu gibi işlev arayın:
PHP Code: PHP Kodu:
if( $h -> db -> column_exists ( 'tablename' , 'columnname' )) { ... do something ... }
Here's the full code for the functions: İşte fonksiyonlar için tam kod:
PHP Code: PHP Kodu:
/**
* Check if table exists
*
* @param string $table2check
* @return bool
*
* Notes: This is a custom function for Hotaru CMS
*/
function table_exists ( $table2check ) {
foreach ( $this -> get_col ( "SHOW TABLES" , 0 ) as $table_name ) {
if( $table_name == DB_PREFIX . $table2check ) {
return true ;
}
}
return false ;
}
/**
* Check if table empty
*
* @param string $table2check
* @return bool
*
* Notes: This is a custom function for Hotaru CMS
*/
function table_empty ( $table2check ) {
$rowcount = $this -> get_var ( $this -> prepare ( "SELECT COUNT(*) FROM " . DB_PREFIX . $table2check ));
if( $rowcount && $rowcount > 0 ) {
return false ; // table not empty
} else {
return true ; // table is empty
}
}
/**
* Check if table column exists
*
* @param string $table2check
* @param string $column
* @return bool
*
* Notes: This is a custom function for Hotaru CMS
*/
function column_exists ( $table2check , $column )
{
$sql = "SHOW COLUMNS FROM " . DB_PREFIX . $table2check ;
foreach ( $this -> get_col ( $sql , 0 ) as $column_name )
{
if ( $column_name == $column ) {
return true ;
}
}
return false ;
}
Bu Blogda Ara
ezqsl etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
ezqsl etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
17 Temmuz 2010 Cumartesi
En Popüler Php veritabanı Sınıfı EzSql
ezSQL Veritabanı (ler kullanmak için gülünç) PHP betikleri içinde kolaylaştıran bir widgettır. It is fully documented with many easy to understand examples. Bu tamamen çok kolay örnekleri anlamak için belgelenmiştir. mySQL version available, Oracle coming soon. mySQL sürümü, Oracle yakında.
By : jv Gönderen: jv
ezSQL is a widget that makes it ridiculously easy for you to use database(s) within your PHP scripts. ezSQL Veritabanı (ler kullanmak için gülünç) PHP betikleri içinde kolaylaştıran bir widgettır.
This widget is a php file that you include at the top of your script. Bu widget size komut üst kısmında yer bir php dosyasıdır. Then, instead of using std php database functions listed in the php manual, you use a much smaller (and easier) set of ezSQL functions. Daha sonra, yerine std php veritabanı fonksiyonları php manuel listelenen kullanarak, kullanmak çok (daha küçük ve daha kolay) ezSQL fonksiyonlar dizisi.
ezSQL can dramatically increase development time and in most cases will streamline your code and make things run faster as well as making it very easy to debug and optimise your database queries. ezSQL ölçüde geliştirme zamanı artırabilir ve çoğu durumda kodunuzu aerodinamik ve işler daha hızlı hem çok hata ayıklamak kolay yapım olarak çalıştırın ve veritabanı sorgularını optimize olun.
The debug system draws a neat table showing exactly what your query was and results are. Hata ayıklama sistemi düzgün bir tablo tam olarak ne Sorgunuzla ve sonuçları gösteren çizer.
Please read through these examples to see how easy using databases can be using ezSQL. Bu örnekler üzerinden ne kadar kolay kullanarak veritabanları ezSQL kullanarak görmek için okuyun.
------------------------------------------------------- -------------------------------------------------- -----
Example 1 Örnek 1
------------------------------------------------------- -------------------------------------------------- -----
// Select multiple records from the database.. veritabanı .. dan / / Birden fazla kayıt
$results = $db->get_results("SELECT name, email FROM users"); $ Sonuç = $ db-> get_results ("SELECT ad, email FROM kullanıcı");
foreach ( $results as $user ) foreach ($ kullanıcı olarak sonuçlar)
{ (
// Access data using object syntax / / Access veri sözdizimi nesne kullanarak
echo $user->name; $ User-> isim echo;
echo $user->email; $ User-> email echo;
} )
---------------------------------------------------- -------------------------------------------------- -
Example 2 Örnek 2
---------------------------------------------------- -------------------------------------------------- -
// Get one row from the database.. / / Veritabanı .. dan bir satır alın
$user = $db->get_row("SELECT name,email FROM users WHERE id = 2"); $ User = $ db-> get_row ("SELECT ad, email FROM kullanıcı WHERE = 2" id);
echo $user->name; $ User-> isim echo;
echo $user->email; $ User-> email echo;
---------------------------------------------------- -------------------------------------------------- -
Example 3 Örnek 3
---------------------------------------------------- -------------------------------------------------- -
// Get one variable from the database.. / / Veritabanı .. tek bir değişken alın
$var = $db->get_var("SELECT count(*) FROM users"); $ Var = $ db-> get_var ("SELECT count (*) FROM kullanıcı");
echo $var; $ Var echo;
---------------------------------------------------- -------------------------------------------------- -
Example 4 Örnek 4
---------------------------------------------------- -------------------------------------------------- -
// Insert into the database / / Ekle veritabanına
$db->query("INSERT INTO users (id, name, email) VALUES (NULL,'Justin','jv@foo.com')"); $ Db-> sorgu ("INSERT INTO kullanıcıları (isim, e-posta) VALUES (NULL, 'Justin', 'jv@foo.com')"); id
---------------------------------------------------- -------------------------------------------------- -
Example 5 Örnek 5
---------------------------------------------------- -------------------------------------------------- -
// Update the database / / Güncelleme veritabanı
$db->query("UPDATE users SET name = 'Justin' WHERE id = 2)"); $ Db-> sorgu ("UPDATE kullanıcılar SET name = 'Justin' WHERE id = 2)");
---------------------------------------------------- -------------------------------------------------- -
Example 6 (for debugging) Örnek 6 (hata ayıklama için)
---------------------------------------------------- -------------------------------------------------- -
// Display last query and all associated results / / Ekran son sorgu ve tüm sonuçlar ilişkili
$db->debug(); $ Db-> debug ();
---------------------------------------------------- -------------------------------------------------- -
Example 7 (for debugging) Örnek 7 (hata ayıklama için)
---------------------------------------------------- -------------------------------------------------- -
// Display the structure and contents of query results (or any variable) / / Ekran yapısı ve sorgu sonucu (ya da herhangi bir değişken) içeriği
$results = $db->get_results("SELECT name, email FROM users"); $ Sonuç = $ db-> get_results ("SELECT ad, email FROM kullanıcı");
$db->vardump($results); $ Db-> vardump ($ sonuçları);
---------------------------------------------------- -------------------------------------------------- -
Example 8 Örnek 8
---------------------------------------------------- -------------------------------------------------- -
// Get 'one column' (based on index) from a query.. / / '(Endeksi) bir sorgu .. dan sütun alın
$names = $db->get_col("SELECT name,email FROM users",0) $ Isim = $ db-> get_col ("SELECT ad, email FROM kullanıcı", 0)
foreach ( $names as $name ) foreach ($ isim gibi isimler)
{ (
echo $name; $ Name echo;
} )
// Get another column from the previous (cached) query results.. / / Önceki (zula) sorgu sonuçlarından başka bir sütun .. alın
$emails = $db->get_col(null,1) $ Emails = $ db-> get_col (null, 1)
foreach ( $emails as $email ) foreach ($ e-posta olarak e-postalar)
{ (
echo $email; $ Email echo;
} )
---------------------------------------------------- -------------------------------------------------- -
Example 9 Örnek 9
---------------------------------------------------- -------------------------------------------------- -
// Map out the full schema of any given database.. / / Herhangi bir veritabanı .. tam şeması dışarı Haritası
$db->select("my_database"); $ Db-> select ("my_database");
foreach ( $db->get_col("SHOW TABLES",0) as $table_name ) foreach ($ db-> get_col ("SHOW TABLOLAR", 0) olarak $ tablo_ismi)
{ (
$db->debug(); $ Db-> debug ();
$db->get_results("DESC $table_name"); $ Db-> get_results ("DESC $ tablo_ismi");
} )
$db->debug(); $ Db-> debug ();
işte indime adresi
http://www.codewalkers.com/codefiles/179_ez_sql.zip
By : jv Gönderen: jv
ezSQL is a widget that makes it ridiculously easy for you to use database(s) within your PHP scripts. ezSQL Veritabanı (ler kullanmak için gülünç) PHP betikleri içinde kolaylaştıran bir widgettır.
This widget is a php file that you include at the top of your script. Bu widget size komut üst kısmında yer bir php dosyasıdır. Then, instead of using std php database functions listed in the php manual, you use a much smaller (and easier) set of ezSQL functions. Daha sonra, yerine std php veritabanı fonksiyonları php manuel listelenen kullanarak, kullanmak çok (daha küçük ve daha kolay) ezSQL fonksiyonlar dizisi.
ezSQL can dramatically increase development time and in most cases will streamline your code and make things run faster as well as making it very easy to debug and optimise your database queries. ezSQL ölçüde geliştirme zamanı artırabilir ve çoğu durumda kodunuzu aerodinamik ve işler daha hızlı hem çok hata ayıklamak kolay yapım olarak çalıştırın ve veritabanı sorgularını optimize olun.
The debug system draws a neat table showing exactly what your query was and results are. Hata ayıklama sistemi düzgün bir tablo tam olarak ne Sorgunuzla ve sonuçları gösteren çizer.
Please read through these examples to see how easy using databases can be using ezSQL. Bu örnekler üzerinden ne kadar kolay kullanarak veritabanları ezSQL kullanarak görmek için okuyun.
------------------------------------------------------- -------------------------------------------------- -----
Example 1 Örnek 1
------------------------------------------------------- -------------------------------------------------- -----
// Select multiple records from the database.. veritabanı .. dan / / Birden fazla kayıt
$results = $db->get_results("SELECT name, email FROM users"); $ Sonuç = $ db-> get_results ("SELECT ad, email FROM kullanıcı");
foreach ( $results as $user ) foreach ($ kullanıcı olarak sonuçlar)
{ (
// Access data using object syntax / / Access veri sözdizimi nesne kullanarak
echo $user->name; $ User-> isim echo;
echo $user->email; $ User-> email echo;
} )
---------------------------------------------------- -------------------------------------------------- -
Example 2 Örnek 2
---------------------------------------------------- -------------------------------------------------- -
// Get one row from the database.. / / Veritabanı .. dan bir satır alın
$user = $db->get_row("SELECT name,email FROM users WHERE id = 2"); $ User = $ db-> get_row ("SELECT ad, email FROM kullanıcı WHERE = 2" id);
echo $user->name; $ User-> isim echo;
echo $user->email; $ User-> email echo;
---------------------------------------------------- -------------------------------------------------- -
Example 3 Örnek 3
---------------------------------------------------- -------------------------------------------------- -
// Get one variable from the database.. / / Veritabanı .. tek bir değişken alın
$var = $db->get_var("SELECT count(*) FROM users"); $ Var = $ db-> get_var ("SELECT count (*) FROM kullanıcı");
echo $var; $ Var echo;
---------------------------------------------------- -------------------------------------------------- -
Example 4 Örnek 4
---------------------------------------------------- -------------------------------------------------- -
// Insert into the database / / Ekle veritabanına
$db->query("INSERT INTO users (id, name, email) VALUES (NULL,'Justin','jv@foo.com')"); $ Db-> sorgu ("INSERT INTO kullanıcıları (isim, e-posta) VALUES (NULL, 'Justin', 'jv@foo.com')"); id
---------------------------------------------------- -------------------------------------------------- -
Example 5 Örnek 5
---------------------------------------------------- -------------------------------------------------- -
// Update the database / / Güncelleme veritabanı
$db->query("UPDATE users SET name = 'Justin' WHERE id = 2)"); $ Db-> sorgu ("UPDATE kullanıcılar SET name = 'Justin' WHERE id = 2)");
---------------------------------------------------- -------------------------------------------------- -
Example 6 (for debugging) Örnek 6 (hata ayıklama için)
---------------------------------------------------- -------------------------------------------------- -
// Display last query and all associated results / / Ekran son sorgu ve tüm sonuçlar ilişkili
$db->debug(); $ Db-> debug ();
---------------------------------------------------- -------------------------------------------------- -
Example 7 (for debugging) Örnek 7 (hata ayıklama için)
---------------------------------------------------- -------------------------------------------------- -
// Display the structure and contents of query results (or any variable) / / Ekran yapısı ve sorgu sonucu (ya da herhangi bir değişken) içeriği
$results = $db->get_results("SELECT name, email FROM users"); $ Sonuç = $ db-> get_results ("SELECT ad, email FROM kullanıcı");
$db->vardump($results); $ Db-> vardump ($ sonuçları);
---------------------------------------------------- -------------------------------------------------- -
Example 8 Örnek 8
---------------------------------------------------- -------------------------------------------------- -
// Get 'one column' (based on index) from a query.. / / '(Endeksi) bir sorgu .. dan sütun alın
$names = $db->get_col("SELECT name,email FROM users",0) $ Isim = $ db-> get_col ("SELECT ad, email FROM kullanıcı", 0)
foreach ( $names as $name ) foreach ($ isim gibi isimler)
{ (
echo $name; $ Name echo;
} )
// Get another column from the previous (cached) query results.. / / Önceki (zula) sorgu sonuçlarından başka bir sütun .. alın
$emails = $db->get_col(null,1) $ Emails = $ db-> get_col (null, 1)
foreach ( $emails as $email ) foreach ($ e-posta olarak e-postalar)
{ (
echo $email; $ Email echo;
} )
---------------------------------------------------- -------------------------------------------------- -
Example 9 Örnek 9
---------------------------------------------------- -------------------------------------------------- -
// Map out the full schema of any given database.. / / Herhangi bir veritabanı .. tam şeması dışarı Haritası
$db->select("my_database"); $ Db-> select ("my_database");
foreach ( $db->get_col("SHOW TABLES",0) as $table_name ) foreach ($ db-> get_col ("SHOW TABLOLAR", 0) olarak $ tablo_ismi)
{ (
$db->debug(); $ Db-> debug ();
$db->get_results("DESC $table_name"); $ Db-> get_results ("DESC $ tablo_ismi");
} )
$db->debug(); $ Db-> debug ();
işte indime adresi
http://www.codewalkers.com/codefiles/179_ez_sql.zip
Kaydol:
Kayıtlar (Atom)