Inicio > PHP > Usar base de datos externa en wordpress

USAR BASE DE DATOS EXTERNA EN WORDPRESS

22/04/2018PHP ME GUSTA

 

Hace poco he estado mirando como funcionaba wordpress y me surgió la duda si con wordpress se podía trabajar con otras bases de datos aparte de la bases de datos de wordpress. Para poder conectarse a otra base de datos hay que usar el objeto wpdb.
Voy a poner un ejemplo:

$bd = new wpdb('dbuser', 'dbpassword', 'dbname', 'dbhost');

$bd ->show_errors();
$contactos = $bd -> get_results("SELECT nombre,telefono FROM contactos");
foreach ($contactos as $contacto) {
echo $contacto->nombre .' '. $contacto-telefono;
}



Espero que os haya servido.


 


Comentarios

You really make it seem so easy along with your presentation however I find this topic to be actually something which I believe I might never understand. It kind of feels too complicated and very vast for me. I'm looking ahead to your subsequent post, I'll attempt to get the hold of it! http://amz.kiev.ua/link/go.php?url=http://www.mbet88vn.com

11/07/2018 por 188bet

Hi! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no back up. Do you have any methods to protect against hackers? http://www.incorporation.ru/redirect.php?url=http://alternatif188bet.com

12/07/2018 por link 188bet