<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forum CakePHP.org.pl - habtm]]></title>
		<link>http://forum.cakephp.org.pl/topic/78/habtm/</link>
		<description><![CDATA[Najświeższe odpowiedzi w habtm.]]></description>
		<lastBuildDate>Mon, 06 Jul 2009 12:54:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/373/#p373</link>
			<description><![CDATA[<p>Zalezy czy dodasz do definicji pola<br />ON UPDATE CURRENT_TIMESTAMP<br />czy nie</p>]]></description>
			<author><![CDATA[dummy@example.com (duke_piotr)]]></author>
			<pubDate>Mon, 06 Jul 2009 12:54:01 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/373/#p373</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/371/#p371</link>
			<description><![CDATA[<p>Witam</p><p>id02009 - probowalem tak jak napisales na rozne sposoby, niestety nie dziala, cake operuje tylko na worker_id i workplace_id - dodanie recznie danych nic nie daje <img src="http://forum.cakephp.org.pl/img/smilies/hmm.png" width="15" height="15" alt="hmm" /> imo tak to powinno wygladac</p><p>carlin - zrobilem. Dziala, jest tylko blad przy odczycie, ale zapis poprawny. W koncu zrobilem tak, ze ustawilem habtm i sposob alfabeta na raz <img src="http://forum.cakephp.org.pl/img/smilies/tongue.png" width="15" height="15" alt="tongue" /> odczyt realizuje przez habtm, zapis - sposob alfabeta <img src="http://forum.cakephp.org.pl/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /> troszke nie poprawnie z punktu widzenia modelowania bd ale dziala. Co prawda tablica zwracana przez sql jest ekhm... duza, ale to tylko kwestia ustawienia paginacji, by nie bylo ogromnych transferow danych w jednym czasie.</p><p>duke_piotr - w sumie nie pomyslalem. Wygodnie jakby baza zalatwila to za cake, tylko nie wiem jak to sie bedzie mialo do polecenia UPDATE czy w kolumnie data, zostanie wstawiona aktualna wartosc czy zostanie ta stara - chodzi tu o poprawienie stanowiska w sytuacji gdy uzytkownik wprowadzajacy pracownika sie pomyli i bedzie chcial mu poprawic stanowisko (a nie zmienic na nowe, obowiazujace od danej daty) - przetestuje to i dam znac jak wyszlo</p><p>Dziekuje wszystkim za pomoc i ide walczyc dalej <img src="http://forum.cakephp.org.pl/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (dredd)]]></author>
			<pubDate>Mon, 06 Jul 2009 09:15:12 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/371/#p371</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/368/#p368</link>
			<description><![CDATA[<p>@dredd -&gt; a z poziomu SQl nowa kolumna TIMESTAMP nie wystarczy? Nie musisz nic uzupełniac tylko odczytujesz date.</p>]]></description>
			<author><![CDATA[dummy@example.com (duke_piotr)]]></author>
			<pubDate>Mon, 06 Jul 2009 08:41:57 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/368/#p368</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/367/#p367</link>
			<description><![CDATA[<p>A może spróbować w tym modelu WorkersWorkplace dodać funkcje <a href="http://book.cakephp.org/view/683/beforeSave">beforeSave</a> i jakoś wypełnić te pole. Nigdy nie próbowałem ale może ...</p>]]></description>
			<author><![CDATA[dummy@example.com (rocichy)]]></author>
			<pubDate>Mon, 06 Jul 2009 06:57:45 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/367/#p367</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/366/#p366</link>
			<description><![CDATA[<p>Cake przy habtm tworzy automagicznie model WorkersWorkplace, więc możesz spróbować zrobić to w taki sposób:<br />$this-&gt;data[&#039;WorkersWorkplace&#039;][&#039;dodatkowa_kolumna&#039;] = &#039;tysioncpińcset&#039;;<br />$this-&gt;Worker-&gt;save($this-&gt;data); //albo saveAll();</p><p>daj znać, czy działa.</p>]]></description>
			<author><![CDATA[dummy@example.com (id02009)]]></author>
			<pubDate>Sat, 04 Jul 2009 20:31:54 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/366/#p366</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/365/#p365</link>
			<description><![CDATA[<p>hej. Dokładnie tak jak napisałeś. Z habtm są problemy i chyba najłatwiej jest to zrobić ręcznie ustawiając tabelę łączącą tak jak napisałeś. Bynajmniej ja tak zrobiłem i mogę dodawać dowolną ilość dodatkowych pól.</p>]]></description>
			<author><![CDATA[dummy@example.com (carlin)]]></author>
			<pubDate>Sat, 04 Jul 2009 14:11:08 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/365/#p365</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/364/#p364</link>
			<description><![CDATA[<p>Witam mam podobny problem. Mam zrobic historie zatrudnienia, dwie tabelki <strong>workers</strong> i <strong>workplaces</strong>, tabela laczaca <strong>workers_workplaces</strong> i przy habtm odczyt danych jest bez problemu, jednakze tabelka przejsciowa musi miec dodatkowa kolumne data, by pamietac kiedy dane stanowisko zostalo zmienione. Przy zapisywaniu nie jest ona wypelniania mimo ze w $this-&gt;data ustawiam dodatkowa kolumne.</p><p>Wiem ze rozwiazanie jest powyzej, ale cos nie moge skumac - generalnie olac habtm i zrobic recznie tak jak zaporponowal alfabeta?<br />Czyli stworzyc dowolna tabele (model - wg standardow cakephp - workers_workplaces) i workers dac hasMany workers_workplaces, w workers_workplaces belongsTo worker i belongsTo workplaces?</p>]]></description>
			<author><![CDATA[dummy@example.com (dredd)]]></author>
			<pubDate>Fri, 03 Jul 2009 09:10:47 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/364/#p364</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/359/#p359</link>
			<description><![CDATA[<p>Dzięki, problem rozwiązany.</p>]]></description>
			<author><![CDATA[dummy@example.com (carlin)]]></author>
			<pubDate>Sat, 27 Jun 2009 16:28:02 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/359/#p359</guid>
		</item>
		<item>
			<title><![CDATA[Odp: habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/353/#p353</link>
			<description><![CDATA[<p>1.<br />Do tabeli pośredniej orders_products dołącz dodatkową kolumnę. <br />Ja miałem problemy z działaniem związków HABTM po takim manewrze więc napisałem własny bahavior dla tego modelu.<br />Z tego co pamiętam udało mi się działać z jedną kolumną dodatkową ale przy 2 już były problemy.</p><p>albo prościej</p><p>2.<br />Do modelu Orders dodać hasMany Details. W modelu Details zrobić belongsTo Order. Można też dodać belongsTo Product.<br />W tym modelu trzymać szczegóły zamówienia tj.</p><p>order_id INT UNSIGNED NOT NULL<br />product_id INT UNSIGNED <br />ile_sztuk INT UNSIGNED<br />.....<br />itd. itp.</p>]]></description>
			<author><![CDATA[dummy@example.com (alfabeta)]]></author>
			<pubDate>Mon, 22 Jun 2009 08:02:02 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/353/#p353</guid>
		</item>
		<item>
			<title><![CDATA[habtm]]></title>
			<link>http://forum.cakephp.org.pl/post/352/#p352</link>
			<description><![CDATA[<p>Witam,</p><p>Mam następujący problem. Posiadam dwie tabele: Orders, Products, ponieważ potrzebuje do jednego zamówienia przypisać wiele produktów skorzystałem z habtm i stworzyłem tabele łączącą orders_products. Model Order i Product&nbsp; korzystają z &#039;extendAssociations&#039;:</p><p>var $actsAs&nbsp; &nbsp;= array(&#039;extendAssociations&#039;);</p><p>oraz posiadają relację &#039;hasAndBelongsToMany&#039;.</p><br /><p>W kontrolerze orders_controller mam funkcję dodającą zamówienie:</p><p>function addOrd() {<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;set(&#039;products&#039;, $this-&gt;Order-&gt;Product-&gt;find(&#039;list&#039;, array(&#039;fields&#039; =&gt; array(&#039;Product.id&#039;, &#039;Product.Nazwa&#039;))));<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;set(compact(&#039;products&#039;));</p><p>&nbsp; &nbsp; &nbsp; &nbsp; if (!empty($this-&gt;data)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( $this-&gt;Order-&gt;saveAll($this-&gt;data)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;redirect(&#039;/&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }</p><p>W odpowiadającym tej funkcji widoku mam taką formułę:</p><br /><p>echo $form-&gt;input( &#039;Product.Product&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; array( &#039;type&#039;=&gt;&#039;select&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;multiple&#039;=&gt;&#039;true&#039;,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;options&#039;=&gt;$products,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;label&#039;=&gt;&#039;Produkty:&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; );</p><p>Dodaje zamówienie i zaznaczam z ctrl kolejne produkty. Działa poprawnie. Chciałbym jednak dodatkowo do każdego zaznaczonego produktu dodawać ilość sztuk czyli żeby do kazdego rekordu w orders_products dodawać pole &#039;Sztuki&#039;. Jeśli ktoś wie jak to można zrealizować to będę wdzięczny. Dziękuje z góry.</p><p>Pozdrawiam.</p>]]></description>
			<author><![CDATA[dummy@example.com (carlin)]]></author>
			<pubDate>Wed, 17 Jun 2009 21:36:18 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/352/#p352</guid>
		</item>
	</channel>
</rss>
