/ Published in: PHP
A PHP function to get a Record Set using ADOdb Library.
It takes the (SQL) query as an argument. For INSERT queries. NOTE: A call for a query.
It also need next variables: $dbhost,$dbuser,$dbpasswd,$dbname (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 INSERT queries. NOTE: A call for a query.
It also need next variables: $dbhost,$dbuser,$dbpasswd,$dbname (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_insert($sql){ global $db_host,$db_user,$db_passwd,$db_name; $conn=ADONewConnection('mysql'); //Instancia de ADODB para proveedor MySQL $conn->Connect($db_host,$db_user,$db_passwd,$db_name) ; // Connexion a MySQL $result=$conn->Execute("SET NAMES UTF8 ;"); $rs=$conn->Execute($sql); // Ejecutar SQL y devuelve un ADORecordSet $ID=$conn->Insert_ID(); //Retorna el ID del registro insertado $conn->Close(); return $ID; }
URL: http://phplens.com/adodb/