/ Published in: PHP
A PHP function to get a Record Set using ADOdb Library.
It takes the (SQL) query as an argument. For SELECT,UPDATE and DELETE queries.
It also need next variables: $db_host,$db_user,$db_passwd,$db_name (data from de bbdd connexion). Can be declared in the document itself.
It returns the Record Set.
It needs the ADOdb Library for php.
It takes the (SQL) query as an argument. For SELECT,UPDATE and DELETE queries.
It also need next variables: $db_host,$db_user,$db_passwd,$db_name (data from de bbdd connexion). Can be declared in the document itself.
It returns the Record Set.
It needs the ADOdb Library for php.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function db_query($sql){ global $db_host,$db_user,$db_passwd,$db_name; //Agafa variables globals (fora de la funcio). $conn=ADONewConnection('mysql'); //Instancia de ADODB para proveedor MySQL. Es pot elegir motor (segons parametre, podria ser oracle...) $conn->Connect($db_host,$db_user,$db_passwd,$db_name) ; // Connexion a MySQL. Usa el metodo Connect.. $result=$conn->Execute("SET lc_time_names = 'ca_ES' ;"); //Per adoptar idioma castellano� (Per errors...) $result=$conn->Execute("SET NAMES UTF8 ;"); //Pel joc de caracters $rs=$conn->Execute($sql); // Ejecutar SQL y devuelve un ADORecordSet $conn->Close(); return $rs; //Funcion devuelve todo el ADORecordSet. }
URL: http://phplens.com/adodb/