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

search for in the

mysql_list_fields> <mysql_insert_id
[edit] Last updated: Fri, 24 May 2013

view this page in

mysql_list_dbs

(PHP 4, PHP 5)

mysql_list_dbsList databases available on a MySQL server

Avertizare

Această extensie este dezaprobată începând cu PHP 5.5.0 și va fi eliminată în viitor. În locul ei trebuie utilizate extensiile MySQLi sau PDO_MySQL. Vedeți de asemenea ghidul MySQL: selectarea unei API și FAQ asociat pentru mai multe informații. Alternative ale acestei funcții includ:

  • SQL Query: SHOW DATABASES

Descrierea

resource mysql_list_dbs ([ resource $link_identifier = NULL ] )

Returns a result pointer containing the databases available from the current mysql daemon.

Avertizare

Această funcție este DEZAPROBATĂ începând cu PHP 5.4.0. Utilizarea acestei funcții este foarte nerecomandabilă.

Parametri

link_identifier

Conexiunea MySQL. Dacă identificatorul legăturii nu este specificat, se presupune că este ultima legătură deschisă cu ajutorul mysql_connect(). Dacă nu este găsită nici o astfel de legătură, se va încerca crearea uneia prin apelul mysql_connect () fără argumente. În caz că nici o conexiune nu este găsită sau stabilită, se va genera o eroare de nivelul E_WARNING.

Valorile întoarse

Returns a result pointer resource on success, or FALSE on failure. Use the mysql_tablename() function to traverse this result pointer, or any function for result tables, such as mysql_fetch_array().

Exemple

Example #1 mysql_list_dbs() example

<?php
// Usage without mysql_list_dbs()
$link mysql_connect('localhost''mysql_user''mysql_password');
$res mysql_query("SHOW DATABASES");

while (
$row mysql_fetch_assoc($res)) {
    echo 
$row['Database'] . "\n";
}

// Deprecated as of PHP 5.4.0
$link mysql_connect('localhost''mysql_user''mysql_password');
$db_list mysql_list_dbs($link);

while (
$row mysql_fetch_object($db_list)) {
     echo 
$row->Database "\n";
}
?>

Exemplul de mai sus va afișa ceva similar cu:

database1
database2
database3

Note

Notă:

Pentru compatibilitatea cu versiunile anterioare, următorul pseudonim dezaprobat poate fi utilizat: mysql_listdbs()

Vedeți de asemenea



add a note add a note User Contributed Notes mysql_list_dbs - [2 notes]
up
1
theriault
10 months ago
Another alternative to this function is:

SQL Query: SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
up
0
matjung at hotmail dot com
3 years ago
The result pointer contains only the databases for which the mysql_user has the select priviledge granted.

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