<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум PHP-MyAdmin.RU &mdash; вывод данных из нескольких баз данных MVC]]></title>
	<link rel="self" href="https://forum.php-myadmin.ru/extern.php?action=feed&amp;tid=4085&amp;type=atom" />
	<updated>2015-06-18T03:18:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.php-myadmin.ru/viewtopic.php?id=4085</id>
		<entry>
			<title type="html"><![CDATA[Re: вывод данных из нескольких баз данных MVC]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=26436#p26436" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[St-137]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=7125</uri>
			</author>
			<updated>2015-06-18T03:18:48Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=26436#p26436</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: вывод данных из нескольких баз данных MVC]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=26435#p26435" />
			<content type="html"><![CDATA[<p>Не знаю как этот класс работает с запросами, поэтому конкретно ничего подсказать не смогу. По приведенному коду не понятно как можно объединить запросы или вывести их раздельно.</p><p>Добавить вторую функцию можно, но перед ее выводом необходимо ее выполнить, после чего уже можно выводить в HTML.</p>]]></content>
			<author>
				<name><![CDATA[Hanut]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=181</uri>
			</author>
			<updated>2015-06-17T18:11:25Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=26435#p26435</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[вывод данных из нескольких баз данных MVC]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=26433#p26433" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[St-137]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=7125</uri>
			</author>
			<updated>2015-06-17T02:24:22Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=26433#p26433</id>
		</entry>
</feed>
