Home
Homepage
Downloads
Downloads
Forums
Forums
Your Account
Il Tuo Account
IngegneriConLePalle.com - Il sito degli Studenti della Facoltà di Ingegneria di Forlì
Promotions


Online Chat
Vuoi cambiar Nome?!
/n tuonome cambia nick
Scegli la Tua Chat 
MobileFissa
PopupOff

Menu
 Homepage
 Utenti
 Il tuo profilo
 Lista Membri
 Blog Utenti
 Firma il Guestbook!
 Contatta Web Master
 Passaparola!!!!
 Community
 Galleria Foto
 Salagiochi
 Forums
 Messaggi Privati
 Cruciverba
 Sudoku
 WebChat
 Calendario Eventi
 Torneo Fantacalcio
 Documenti
 Risorse
 Downloads
 Loghi x Cellulari
 Web Links
 Barzellette
 Cerca nel Sito
 Documenti
 Argomenti
 News
 Aggiungi News
 Digital-Sat News
 AvantGo
 Servizi
 Previsioni Meteo
 Elenco Telefonico
 Video Musicali
 Radio Streaming
 Serata in TV
 Stradario d'Italia
 GoogleMaps
 Utilitą
 Php-Nuke Tools
 GUIstuff+
 Multi Search Engine
 Codice Fiscale
 Underground Search
 Submit Engines
 Open Directory
 PHP-Nuke HOWTO
 Statistiche
 Statistiche del Sito
 Analysis
 Top 10
 Inverno 2005
 Bollettino Neve
 WebCam Neve
 Site Map
 RSS Articoli 0.91
 RSS Articoli 2.0
 RSS Downloads 0.91
 RSS Downloads 2.0
 RSS Links 0.91
 RSS Links 2.0
 RSS Forums 0.91
 RSS Forums 2.0
 RSS Calendario 0.91
 RSS Calendario 2.0
 ATOM Articoli 0.3
 Spambot Killer

Promotions

Security
_AB_WARNED
We have caught 1656 shameful hackers.

NukeSentinel™ 2.5.17

The syntax of SQL code

28.5. The syntax of SQL code

Aiming at making PHP-Nuke compatible with more databases, the SQL syntax has been transformed to functions, in order to achieve a standard syntax that is independent of the database used. For convenience, let us recall the file sql_layer.php in a somewhat cleaned-up version:

sql_connect($host, $user, $password, $db) (1)
sql_logout($id) (2)
sql_query($query, $id) (3)
sql_num_rows($res) (4)
sql_fetch_row(&$res, $nr) (5)
sql_fetch_array(&$res, $nr) (6)
sql_fetch_object(&$res, $nr) (7)
sql_free_result($res) (8)
(1)
Log into the DB.
(2)
Disconnect from the DB.
(3)
Query.
(4)
Number of Rows.
(5)
Fetch Rows.
(6)
Fetch Array.
(7)
Fetch Object.
(8)
Free Result.

With this syntax you will be able to render all the modifications, blocks or modules you create compatible to all the databases supported by PHP-Nuke, which are:

  • MySQL

  • mSQL

  • PostgreSQL

  • PostgreSQL_local

  • ODBC

  • ODBC_Adabas

  • Interbase

  • Sybase

From version 6.5 and up, PHP-Nuke users the same abstraction layer of phpBB for compatibility reasons. It's very easy and highly tested. Normaly you make a query on MySQL like this:

$sql = "SELECT uid, uname FROM nuke_users";
$result = mysql_query($sql);
list($uid, $uname) = mysql_fetch_row($result);

With the SQL abstraction layer on PHP-Nuke, you would declare $db as a global variable and then write:

$sql = "SELECT uid, uname FROM nuke_users";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);

This will return the array $row[] with the results. If you want to work with more friendly names you should do this:

$uid = $row[uid];
$uname = $row[uname];

But it is much faster for you (and for the system) to use just the array values directly, ie:

echo "Hello $row[uname], Welcome to my site!";

Note that there isn't any "sql_fetch_array", the sql_fetch_row automaticaly will create the array with the results of your query.

The old method using the file sql_layer.php and the variable $dbi is now deprecated. It works for compatibility reasons, but we strongly suggest to any developer making new modules or modifying a module to start using the new method. See also the ADDONS-MODULES file that came with your PHP-Nuke package.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

.:: WebMaster Ing. Francesco Feruzzi :: ©2005 IngegneriConLePalle.com :: Regolamento ::.
Generazione pagina: 0.39 Secondi
Creative Commons License
Eccetto dove diversamente specificato, i contenuti di questo sito sono rilasciati sotto Licenza Creative Commons Attribuzione 2.5.

Add to Google
SEO Stats powered by MyPagerank.Net