Ciao raga,
come faccio a sapere che tabelle sono state installate nel mio
database?
esiste una query particolare?
grazie![]()
Ciao raga,
come faccio a sapere che tabelle sono state installate nel mio
database?
esiste una query particolare?
grazie![]()
SHOW TABLES;
The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand
Tratto dal manuale di PHP
codice:<?php $dbname = 'mysql_dbname'; if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { print 'Could not connect to mysql'; exit; } $result = mysql_list_tables($dbname); if (!$result) { print "DB Error, could not list tables\n"; print 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { print "Table: $row[0]\n"; } mysql_free_result($result); ?>
grazie
ma che vuol dire
mysql_free_result($result);
![]()
$result è di tipo risorse, ovvero non è un tipo specifico di PHP poichè generato al suo esterno. Le risorse generate da mySQL in una query occupano dello spazio (a volte tanto tanto spazio) che viene liberato attraveso questa chiamata. Lo spazio assegnato viene comunque rilasciato al termine dello script php.
in poche parole distrugge il contenuto di quella variabile?
sempre dal manuale......Originariamente inviato da Grino
Tratto dal manuale di PHP
codice:<?php $dbname = 'mysql_dbname'; if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { print 'Could not connect to mysql'; exit; } $result = mysql_list_tables($dbname); if (!$result) { print "DB Error, could not list tables\n"; print 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { print "Table: $row[0]\n"; } mysql_free_result($result); ?>
usaNote: The function mysql_list_tables() is deprecated. It is preferable to use mysql_query() to issue a SQL SHOW TABLES [FROM db_name] [LIKE 'pattern'] statement instead.
SHOW TABLES
semplicemente al posto di mysql_list_tables fai una query e poi procedi normalmente ^^
^^
The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand
ok daniele_dll
cosa si intende per [LIKE 'pattern']
funziona come il normalissimo like nel wherene + ne meno
ti serve se vuoi elencarti solo le tabelle, che ad es, iniziano con una stringa specifica
The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand