{"id":432,"date":"2014-01-09T18:43:10","date_gmt":"2014-01-09T18:43:10","guid":{"rendered":"http:\/\/luisrodriguez.pe\/blog\/?p=432"},"modified":"2014-01-09T18:46:04","modified_gmt":"2014-01-09T18:46:04","slug":"conexion-a-multiples-bases-de-datos-en-codeigniter","status":"publish","type":"post","link":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/","title":{"rendered":"Conexi\u00f3n a multiples bases de datos en Codeigniter"},"content":{"rendered":"<p><a href=\"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\"><img decoding=\"async\" class=\"alignright size-full wp-image-438\" title=\"descarga\" src=\"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\" alt=\"\" width=\"208\" height=\"240\" \/><\/a>Me tope con el requerimiento de utilizar 2 base de datos en distintos servidores para mostrar informaci\u00f3n en unos mantenimientos y resulto facil esta mision aun que me tuvo un rato buscando la solucion pero aqui les detallo como solucionamos este problema.<\/p>\n<p>nos vamos a<\/p>\n<ul>\n<li>\\application\\config\\database.php<\/li>\n<\/ul>\n<div>la variable $db es una array multidimensional donde podemos agregar avrios nombres que esto nos sirve para signar otra base de datos por defecto cuando bajas siempre encuentras el array con el nombre default ahora copiamos lo mismo y le colocamos el nombre de nuestra otra base de datos que no es necesariamente que se llame tal cual como se llama tu base de datos:<br \/>\nejemplo:<br \/>\nel nuevo que agrego<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #000088;\">$db<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'MI_BASE_DE_DATOS'<\/span><span style=\"color: #009900;\">&#93;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>el que esta por defecto<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #000088;\">$db<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'default'<\/span><span style=\"color: #009900;\">&#93;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>le damos los datos de conexion.<\/p>\n<\/div>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #666666; font-style: italic;\">\/*esta esta en otro servidor entonces debemos colocar la ip*\/<\/span>\n<span style=\"color: #000088;\">$db<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'Billing'<\/span><span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'hostname'<\/span><span style=\"color: #009900;\">&#93;<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000ff;\">'xxxxxxxxxxx'<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #000088;\">$db<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'Billing'<\/span><span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'username'<\/span><span style=\"color: #009900;\">&#93;<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000ff;\">'xxxxxxx'<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #000088;\">$db<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'Billing'<\/span><span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">'password'<\/span><span style=\"color: #009900;\">&#93;<\/span> <span style=\"color: #339933;\">=<\/span> xxxxxxxxxxx<span style=\"color: #0000ff;\">';\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>database<span style=\"color: #0000ff;\">'] = '<\/span>billing<span style=\"color: #0000ff;\">';\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>dbdriver<span style=\"color: #0000ff;\">'] = '<\/span>mysqli<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>port<span style=\"color: #0000ff;\">'] = &quot;3306&quot;;\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>dbprefix<span style=\"color: #0000ff;\">'] = '<\/span><span style=\"color: #0000ff;\">';\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>pconnect<span style=\"color: #0000ff;\">'] = TRUE;\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>db_debug<span style=\"color: #0000ff;\">'] = TRUE;\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>cache_on<span style=\"color: #0000ff;\">'] = FALSE;\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>cachedir<span style=\"color: #0000ff;\">'] = '<\/span><span style=\"color: #0000ff;\">';\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>char_set<span style=\"color: #0000ff;\">'] = '<\/span>utf8<span style=\"color: #0000ff;\">';\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>dbcollat<span style=\"color: #0000ff;\">'] = '<\/span>utf8_general_ci<span style=\"color: #0000ff;\">';\n$db['<\/span>Billing<span style=\"color: #0000ff;\">']['<\/span>swap_pre<span style=\"color: #0000ff;\">'] = '<\/span><span style=\"color: #0000ff;\">';\n&nbsp;\n$active_group = '<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">';\n$active_record = TRUE;\n\/*esta es la que tenemos en nuestro servidor*\/\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>hostname<span style=\"color: #0000ff;\">'] = '<\/span>localhost<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>username<span style=\"color: #0000ff;\">'] = '<\/span>xxxx<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>password<span style=\"color: #0000ff;\">'] = '<\/span>xxxxxxxx<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>database<span style=\"color: #0000ff;\">'] = '<\/span>xxxxxxxxx<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>dbdriver<span style=\"color: #0000ff;\">'] = '<\/span>mysqli<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>port<span style=\"color: #0000ff;\">'] = &quot;3306&quot;;\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>dbprefix<span style=\"color: #0000ff;\">'] = '<\/span><span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>pconnect<span style=\"color: #0000ff;\">'] = TRUE;\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>db_debug<span style=\"color: #0000ff;\">'] = TRUE;\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>cache_on<span style=\"color: #0000ff;\">'] = FALSE;\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>cachedir<span style=\"color: #0000ff;\">'] = '<\/span><span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>char_set<span style=\"color: #0000ff;\">'] = '<\/span>utf8<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>dbcollat<span style=\"color: #0000ff;\">'] = '<\/span>utf8_general_ci<span style=\"color: #0000ff;\">';\n$db['<\/span><span style=\"color: #b1b100;\">default<\/span><span style=\"color: #0000ff;\">']['<\/span>swap_pre<span style=\"color: #0000ff;\">'] = '<\/span><span style=\"color: #0000ff;\">';<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>ahora desde un modelo o control podemos activar la conexion a la base de datos por que en codeignter solo tiene una que es la que colocamos pro defecto.<br \/>\ncon esta linea de codigo lo activamos<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>load<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>database<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">&quot;Billing&quot;<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #009900; font-weight: bold;\">TRUE<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>aqui un ejemplo de la conexion desde el modelo<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #000000; font-weight: bold;\">class<\/span> Cuentas_model <span style=\"color: #000000; font-weight: bold;\">extends<\/span> CI_Model <span style=\"color: #009900;\">&#123;<\/span>\n<span style=\"color: #000000; font-weight: bold;\">function<\/span> __construct<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span>\n<span style=\"color: #009900;\">&#123;<\/span>\nparent<span style=\"color: #339933;\">::<\/span>__construct<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n<span style=\"color: #000000; font-weight: bold;\">function<\/span> get_accounts<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span>\n<span style=\"color: #009900;\">&#123;<\/span>\n<span style=\"color: #666666; font-style: italic;\">\/*la conexion a la otra base de datos*\/<\/span>\n<span style=\"color: #000088;\">$db_billing<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>load<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>database<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">&quot;Billing&quot;<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #009900; font-weight: bold;\">TRUE<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #666666; font-style: italic;\">\/*una consulta a esa base de datos*\/<\/span>\n<span style=\"color: #000088;\">$query<\/span><span style=\"color: #339933;\">=<\/span><span style=\"color: #000088;\">$db_billing<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>query<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">&quot;select * from accounts&quot;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #b1b100;\">return<\/span> <span style=\"color: #000088;\">$query<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>result<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>en el controlador<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #000000; font-weight: bold;\">class<\/span> Cuentas <span style=\"color: #000000; font-weight: bold;\">extends<\/span> CI_Controller <span style=\"color: #009900;\">&#123;<\/span>\n&nbsp;\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000000; font-weight: bold;\">function<\/span> __construct<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span>\nparent<span style=\"color: #339933;\">::<\/span>__construct<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>template<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>set_layout<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">'layout.php'<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>load<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>model<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">&quot;Cuentas_model&quot;<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #0000ff;\">&quot;Cuentas&quot;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000000; font-weight: bold;\">function<\/span> index<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span>\n<span style=\"color: #009900;\">&#123;<\/span>\n<span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>template<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>title<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">'Cuentas'<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #666666; font-style: italic;\">\/*llamamos al modelo y jalamos los datos*\/<\/span>\n<span style=\"color: #000088;\">$data<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">&quot;listado&quot;<\/span><span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #339933;\">=<\/span><span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>Cuentas<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>get_accounts<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>template<span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>build<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">'distribuidores\/cuentas\/index'<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #000088;\">$data<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n<span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>en la vista<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"php\" style=\"font-family:monospace;\"><span style=\"color: #b1b100;\">foreach<\/span> <span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000088;\">$listado<\/span> <span style=\"color: #b1b100;\">as<\/span> <span style=\"color: #000088;\">$item<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">:<\/span>\n<span style=\"color: #b1b100;\">echo<\/span> <span style=\"color: #000088;\">$item<\/span><span style=\"color: #339933;\">-&gt;<\/span><span style=\"color: #004000;\">accountcode<\/span><span style=\"color: #339933;\">.<\/span><span style=\"color: #0000ff;\">&quot;&amp;lt;br \/&amp;gt;&quot;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #b1b100;\">endforeach<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p>con esto ya estamos manejando 2 base de datos y si quieren con mas base de datos los mismos pasos pero agregan en el array de base de datos.<\/p>\n","protected":false},"excerpt":{"rendered":"Me tope con el requerimiento de utilizar 2 base de datos en distintos servidores para mostrar informaci\u00f3n en unos mantenimientos y resulto facil esta mision aun que me tuvo un rato buscando la solucion pero aqui les detallo como solucionamos este problema. nos vamos a \\application\\config\\database.php la variable $db es una array multidimensional donde podemos[&#8230;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-432","post","type-post","status-publish","format-standard","hentry","category-framework"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Conexi\u00f3n a multiples bases de datos en Codeigniter - Blog Luis Rodriguez<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Conexi\u00f3n a multiples bases de datos en Codeigniter - Blog Luis Rodriguez\" \/>\n<meta property=\"og:description\" content=\"Me tope con el requerimiento de utilizar 2 base de datos en distintos servidores para mostrar informaci\u00f3n en unos mantenimientos y resulto facil esta mision aun que me tuvo un rato buscando la solucion pero aqui les detallo como solucionamos este problema. nos vamos a applicationconfigdatabase.php la variable $db es una array multidimensional donde podemos[...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Luis Rodriguez\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/luisrodriguez.pe\" \/>\n<meta property=\"article:published_time\" content=\"2014-01-09T18:43:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-01-09T18:46:04+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\" \/>\n<meta name=\"author\" content=\"Luis Rodriguez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@luizmirodriguez\" \/>\n<meta name=\"twitter:site\" content=\"@luizmirodriguez\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Luis Rodriguez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\"},\"author\":{\"name\":\"Luis Rodriguez\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/#\/schema\/person\/ec55de81e01fdaf3533eb78f6a49090c\"},\"headline\":\"Conexi\u00f3n a multiples bases de datos en Codeigniter\",\"datePublished\":\"2014-01-09T18:43:10+00:00\",\"dateModified\":\"2014-01-09T18:46:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\"},\"wordCount\":218,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\",\"articleSection\":[\"Framework\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\",\"url\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\",\"name\":\"Conexi\u00f3n a multiples bases de datos en Codeigniter - Blog Luis Rodriguez\",\"isPartOf\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\",\"datePublished\":\"2014-01-09T18:43:10+00:00\",\"dateModified\":\"2014-01-09T18:46:04+00:00\",\"author\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/#\/schema\/person\/ec55de81e01fdaf3533eb78f6a49090c\"},\"breadcrumb\":{\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage\",\"url\":\"https:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\",\"contentUrl\":\"https:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg\",\"width\":208,\"height\":240},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/luisrodriguez.pe\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Conexi\u00f3n a multiples bases de datos en Codeigniter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/#website\",\"url\":\"https:\/\/luisrodriguez.pe\/blog\/\",\"name\":\"Blog Luis Rodriguez\",\"description\":\"Analytics Developer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/luisrodriguez.pe\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/luisrodriguez.pe\/blog\/#\/schema\/person\/ec55de81e01fdaf3533eb78f6a49090c\",\"name\":\"Luis Rodriguez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/3b0f9734b267ecb38e1860734b4caebda4efa8be9a2bb536862b6a2ba23afa82?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3b0f9734b267ecb38e1860734b4caebda4efa8be9a2bb536862b6a2ba23afa82?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3b0f9734b267ecb38e1860734b4caebda4efa8be9a2bb536862b6a2ba23afa82?s=96&d=mm&r=g\",\"caption\":\"Luis Rodriguez\"},\"description\":\"Hola, Soy Luis Rodriguez, radico en Lima \u2013 Per\u00fa, formado en una carrera inform\u00e1tica, desempe\u00f1ando desde el 2007 como programador web y viendo proyectos desde Front End y Back End a lo que me perfile como Full Stack. Esta Experiencia junto a mi inter\u00e9s en la Anal\u00edtica Web me ayud\u00f3 mucho entender el funcionamiento interno de las herramientas de anal\u00edtica, con las que vengo trabajo activamente desde 2017. Linkedin\",\"sameAs\":[\"http:\/\/luisrodriguez.pe\"],\"url\":\"https:\/\/luisrodriguez.pe\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Conexi\u00f3n a multiples bases de datos en Codeigniter - Blog Luis Rodriguez","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/","og_locale":"es_ES","og_type":"article","og_title":"Conexi\u00f3n a multiples bases de datos en Codeigniter - Blog Luis Rodriguez","og_description":"Me tope con el requerimiento de utilizar 2 base de datos en distintos servidores para mostrar informaci\u00f3n en unos mantenimientos y resulto facil esta mision aun que me tuvo un rato buscando la solucion pero aqui les detallo como solucionamos este problema. nos vamos a applicationconfigdatabase.php la variable $db es una array multidimensional donde podemos[...]","og_url":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/","og_site_name":"Blog Luis Rodriguez","article_publisher":"https:\/\/www.facebook.com\/luisrodriguez.pe","article_published_time":"2014-01-09T18:43:10+00:00","article_modified_time":"2014-01-09T18:46:04+00:00","og_image":[{"url":"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg","type":"","width":"","height":""}],"author":"Luis Rodriguez","twitter_card":"summary_large_image","twitter_creator":"@luizmirodriguez","twitter_site":"@luizmirodriguez","twitter_misc":{"Escrito por":"Luis Rodriguez","Tiempo de lectura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#article","isPartOf":{"@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/"},"author":{"name":"Luis Rodriguez","@id":"https:\/\/luisrodriguez.pe\/blog\/#\/schema\/person\/ec55de81e01fdaf3533eb78f6a49090c"},"headline":"Conexi\u00f3n a multiples bases de datos en Codeigniter","datePublished":"2014-01-09T18:43:10+00:00","dateModified":"2014-01-09T18:46:04+00:00","mainEntityOfPage":{"@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/"},"wordCount":218,"commentCount":0,"image":{"@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage"},"thumbnailUrl":"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg","articleSection":["Framework"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/","url":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/","name":"Conexi\u00f3n a multiples bases de datos en Codeigniter - Blog Luis Rodriguez","isPartOf":{"@id":"https:\/\/luisrodriguez.pe\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage"},"image":{"@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage"},"thumbnailUrl":"http:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg","datePublished":"2014-01-09T18:43:10+00:00","dateModified":"2014-01-09T18:46:04+00:00","author":{"@id":"https:\/\/luisrodriguez.pe\/blog\/#\/schema\/person\/ec55de81e01fdaf3533eb78f6a49090c"},"breadcrumb":{"@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#primaryimage","url":"https:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg","contentUrl":"https:\/\/luisrodriguez.pe\/blog\/wp-content\/uploads\/2014\/01\/descarga.jpg","width":208,"height":240},{"@type":"BreadcrumbList","@id":"https:\/\/luisrodriguez.pe\/blog\/conexion-a-multiples-bases-de-datos-en-codeigniter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/luisrodriguez.pe\/blog\/"},{"@type":"ListItem","position":2,"name":"Conexi\u00f3n a multiples bases de datos en Codeigniter"}]},{"@type":"WebSite","@id":"https:\/\/luisrodriguez.pe\/blog\/#website","url":"https:\/\/luisrodriguez.pe\/blog\/","name":"Blog Luis Rodriguez","description":"Analytics Developer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/luisrodriguez.pe\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Person","@id":"https:\/\/luisrodriguez.pe\/blog\/#\/schema\/person\/ec55de81e01fdaf3533eb78f6a49090c","name":"Luis Rodriguez","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/secure.gravatar.com\/avatar\/3b0f9734b267ecb38e1860734b4caebda4efa8be9a2bb536862b6a2ba23afa82?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3b0f9734b267ecb38e1860734b4caebda4efa8be9a2bb536862b6a2ba23afa82?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3b0f9734b267ecb38e1860734b4caebda4efa8be9a2bb536862b6a2ba23afa82?s=96&d=mm&r=g","caption":"Luis Rodriguez"},"description":"Hola, Soy Luis Rodriguez, radico en Lima \u2013 Per\u00fa, formado en una carrera inform\u00e1tica, desempe\u00f1ando desde el 2007 como programador web y viendo proyectos desde Front End y Back End a lo que me perfile como Full Stack. Esta Experiencia junto a mi inter\u00e9s en la Anal\u00edtica Web me ayud\u00f3 mucho entender el funcionamiento interno de las herramientas de anal\u00edtica, con las que vengo trabajo activamente desde 2017. Linkedin","sameAs":["http:\/\/luisrodriguez.pe"],"url":"https:\/\/luisrodriguez.pe\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/posts\/432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":10,"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":440,"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions\/440"}],"wp:attachment":[{"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/luisrodriguez.pe\/blog\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}