<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум PHP-MyAdmin.RU &mdash; вывод данных из нескольких баз данных MVC]]></title>
		<link>https://forum.php-myadmin.ru/viewtopic.php?id=4085</link>
		<atom:link href="https://forum.php-myadmin.ru/extern.php?action=feed&amp;tid=4085&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «вывод данных из нескольких баз данных MVC».]]></description>
		<lastBuildDate>Thu, 18 Jun 2015 03:18:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: вывод данных из нескольких баз данных MVC]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=26436#p26436</link>
			<description><![CDATA[<p>Там все оказалось довольно просто <img src="https://forum.php-myadmin.ru/img/smilies/smile.png" width="15" height="15" alt="smile" /> <br />$this-&gt;load-&gt;model(&#039;data_model&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $data[&#039;rows&#039;]= $this-&gt;data_model-&gt;getAll();<br />$data[&#039;rows2&#039;]= $this-&gt;data_model-&gt;getAll2();<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;load-&gt;view(&#039;home&#039;, $data); </p><p>ну и соответственно создали функцию&nbsp; getAll2 и во вьюшке вывели форычем rows2<br />А так, Спасибо)))</p>]]></description>
			<author><![CDATA[null@example.com (St-137)]]></author>
			<pubDate>Thu, 18 Jun 2015 03:18:48 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=26436#p26436</guid>
		</item>
		<item>
			<title><![CDATA[Re: вывод данных из нескольких баз данных MVC]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=26435#p26435</link>
			<description><![CDATA[<p>Не знаю как этот класс работает с запросами, поэтому конкретно ничего подсказать не смогу. По приведенному коду не понятно как можно объединить запросы или вывести их раздельно.</p><p>Добавить вторую функцию можно, но перед ее выводом необходимо ее выполнить, после чего уже можно выводить в HTML.</p>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Wed, 17 Jun 2015 18:11:25 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=26435#p26435</guid>
		</item>
		<item>
			<title><![CDATA[вывод данных из нескольких баз данных MVC]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=26433#p26433</link>
			<description><![CDATA[<p>Всем доброго дня! Нужна помощь.<br />Есть такой код в Controllere</p><p>class Site extends CI_Controller {<br />&nbsp; <br />&nbsp; &nbsp;function index(){<br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;load-&gt;model(&#039;data_model&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $data[&#039;rows&#039;]= $this-&gt;data_model-&gt;getAll();<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;load-&gt;view(&#039;home&#039;, $data);&nbsp; <br />&nbsp; &nbsp; &nbsp;}&nbsp; <br />&nbsp; &nbsp;} </p><p>далее такой<br />class Data_model extends Ci_Model {<br /> function getAll (){<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;db-&gt;select(&#039;title, contents&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;db-&gt;from(&#039;data_2&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp;$this-&gt;db-&gt;where(&#039;id&#039;,2);<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $q = $this-&gt;db-&gt;get();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if($q-&gt;num_rows()&gt; 0){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($q-&gt;result() as $row){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data[]=$row;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $data;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }</p><p>ну и на выходе во вьюшке</p><p>&lt;body&gt;<br />&lt;div id=&quot;conteiner&quot;&gt; <br />&nbsp; &lt;?php<br />&nbsp; &nbsp; foreach($rows as $r):?&gt;&nbsp; <br />&nbsp; &nbsp; &lt;h1&gt;&lt;?php echo $r-&gt;title;&nbsp; ?&gt;&lt;/h1&gt;<br />&nbsp; &nbsp;&lt;div&gt;&lt;?php echo $r-&gt;contents;?&gt;&lt;/div&gt; <br />&nbsp; &nbsp;&lt;?php endforeach; ?&gt;<br />&lt;/div&gt;</p><p>Суть вопроса такова есть $this-&gt;db-&gt;from(&#039;data_2&#039;);это одна база данных, а есть база данных <br />$this-&gt;db-&gt;from(&#039;data&#039;); <br />Могу я вывести результат одной функцией запрос к двум базам данных<br />я пробовал создать вторую функцию <br />function getAll2 (){<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;db-&gt;select(&#039;title, contents&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;db-&gt;from(&#039;data&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp;$this-&gt;db-&gt;where(&#039;id&#039;,2);<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $q = $this-&gt;db-&gt;get();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if($q-&gt;num_rows()&gt; 0){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($q-&gt;result() as $row){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data2[]=$row;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $data2;<br />но потом не знаю как во вьюшке вывести</p><p>Всем кто откликнется Спасибо</p>]]></description>
			<author><![CDATA[null@example.com (St-137)]]></author>
			<pubDate>Wed, 17 Jun 2015 02:24:22 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=26433#p26433</guid>
		</item>
	</channel>
</rss>
