<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Defining row id with foreign keys</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>LittleVince on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9580</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9580</guid>
        	        	<description><![CDATA[<p>MamaliFrenchi &#62;</p>
<p>&#160;&#160; Yes, you correctly understood the problem ^^&#160;&#160; Adding a primary key... Why not?</p>
<p>&#160;&#160; At the beginning I didn&#39;t want to add anything else, because I was trying to create short and simple tables, but this may be the most simple solution to setup and to maintain (PHP "split" used this way is not a clean solution to manage data, I think...).</p>
<p>&#160;&#160; I&#39;m gonna try your idea and probably go this way, thank you for this simple and working proposal. (Bonne soir&#233;e et s&#251;rement &#224; bient&#244;t ^^)</p>
</p>
<p>kris &#62;</p>
<p>&#160;&#160; I tried it in my early tests, but it didn&#39;t work: when edited by user, values of both keys change and it&#39;s impossible to find the original row... It may be possible with the use of events (saving values before editing and passing them) but I was looking for a solution more academical than technical. Thanks anyway for this suggest that could work.</p></p>
]]></description>
        	        	<pubDate>Thu, 10 Sep 2009 11:30:44 +0300</pubDate>
        </item>
        <item>
        	<title>kris on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9579</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9579</guid>
        	        	<description><![CDATA[<p>you can always append to posted data two pass both keys </p>
]]></description>
        	        	<pubDate>Thu, 10 Sep 2009 10:47:26 +0300</pubDate>
        </item>
        <item>
        	<title>kris on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9578</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9578</guid>
        	        	<description><![CDATA[<p>you can always append to posted data two pass both keys</p>
]]></description>
        	        	<pubDate>Thu, 10 Sep 2009 10:47:25 +0300</pubDate>
        </item>
        <item>
        	<title>MamaliFrenchi on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9575</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9575</guid>
        	        	<description><![CDATA[<p>If I understand correctly your problem, you have a relation table between 2 other talbes. Why not adding a Primary Key in your realtion table something like RealionID, CarID, DriverID where RelationID is your primary key and DriverID, CarID foreigh key to your other tables. Then you can get all your records with RealionID key. Je te souhaite une exellente journee.</p>
]]></description>
        	        	<pubDate>Thu, 10 Sep 2009 09:03:18 +0300</pubDate>
        </item>
        <item>
        	<title>LittleVince on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9538</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9538</guid>
        	        	<description><![CDATA[<p>Ok... I found a first solution, not really clean but working:</p>
<p>PHP-side, during XML creation, I put the following string:&#160; "driverID<strong> - </strong>carID" (minus symbol is important) in the row cell, as a rowID.</p>
<p>When user edit line, jqGrid sends $driverID and $carID (as edited by user), and $id containing something like: "8-32".</p>
<p>PHP-side, before execution of the editing query, I split content of $id (using the "minus" symbol inserted previously) into $driver and $car.</p>
<p>So I can do my UPDATE query, with "SET" using $driverID and $carID and "WHERE" using $driver and $car...</p>
</p>
<p>It works perfectly, but if anyone has a... cleaner... solution, that would be of interest.</p></p>
]]></description>
        	        	<pubDate>Thu, 10 Sep 2009 02:23:20 +0300</pubDate>
        </item>
        <item>
        	<title>LittleVince on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9537</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9537</guid>
        	        	<description><![CDATA[<p>Thank you for this first step in helping me...</p>
<p>The relation would be "many to many": each row in the jqGrid would show an association, and each driver or car could appear several times.</p>
<p>The dropdown lists are a good idea, I did that at the beginning and it works perfectly.</p>
<p>Now stands the same problem... How to edit an existing row? In other words: what&#39;s the id of an existing row (what id pass to php to make an UPDATE query...) ?</p>
<p>If anybody as an answer to this, it&#39;ll be welcome...</p>
]]></description>
        	        	<pubDate>Thu, 10 Sep 2009 01:38:45 +0300</pubDate>
        </item>
        <item>
        	<title>MamaliFrenchi on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9532</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9532</guid>
        	        	<description><![CDATA[<p>What Exactly you like to achieve? what the relation between Car &#38; drivers? many to many? or 1 to many? I am guessing you want to seletct a Driver, then associate a car to the driver. You need 2 dropdows one to select driver another for car, then save just IDs. for presentation take a look at subgrid, or Tree grid to get some idea. A propos pour un francais tu ecris tres bien en englais.</p>
]]></description>
        	        	<pubDate>Wed, 09 Sep 2009 21:08:01 +0300</pubDate>
        </item>
        <item>
        	<title>LittleVince on Defining row id with foreign keys</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9528</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/defining-row-id-with-foreign-keys#p9528</guid>
        	        	<description><![CDATA[</p>
<p>Hello,</p>
<p>I&#39;m new to jqGrid, and I still have some&#160;difficulties to use this great plugin. Here&#39;s a summary of my problem.</p>
</p>
<p>I&#39;m using two tables:</p>
<p>drivers(driv<span style="text-decoration: underline;">erID</span>, driverName)</p>
<p>cars(<span style="text-decoration: underline;">carID</span>, carName)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (of course, driverID and carID are single primary keys)</p>
<p>So, showing and editing &#8220;drivers&#8221;&#160;in jqGrid is not a problem:</p>
<p>PHP side:&#160;When processing the XML file to display the table, I put driverID in the &#60;row id=&#39;&#39;&#62; part, and driverName in a &#60;cell&#62; part to set a single column &#39;driverName&#39; in jqGrid.</p>
<p>When a driver name is edited in this column, I use the PHP/MySQL query: UPDATE drivers SET driverName=&#39;$driverName&#39; WHERE driverID=&#39;$id&#39;</p>
</p>
<p>Ok&#8230; But now I need one more table: drivers_cars(#driverID, #carID) which is made of two foreign keys, to allow the user of the webpage to associate any driver to any car (several cars per driver, and several drivers per car). New associations will be generated&#160;by creating new rows in a dedicated jqGrid datagrid.</p>
</p>
<p>What to put in the XML file (row and cells) to display the content of the table ?</p>
<p>I tried the following,&#160;with PHP/MySQL: SELECT driverID, carID FROM drivers_cars</p>
<p>My XML looks like that: &#60;row id=&#39;&#39;&#62; &#60;cell&#62;<strong>driverID</strong>&#60;/cell&#62; &#60;cell&#62;<strong>carID</strong>&#60;/cell&#62; &#60;/row&#62;</p>
<p>In jqGrid there are two columns &#8220;driverID&#8221; and &#8220;carID&#8221;, their content is ok.</p>
<p>But when the user wants to edit a line, what updating query shoud I write?</p>
<p>UPDATE drivers_cars SET driverID=&#39;$driverID&#39; WHERE &#8230; ?</p>
</p>
<p>I hope it wasn&#39;t too confusing to read, and maybe I&#39;m not using the right method to do that. But at this time I don&#39;t understand how to show/edit a table that uses only foreign keys, because I always identify my rows with XML, using &#60;row id=<em>&#39;primary key&#39;</em>&#62;.</p>
</p>
<p>Thanks for any help you could bring to me.</p>
<p>Vincent</p>
<p>(ps: I&#39;m french, please forgive any bad english in this post)</p></p>
]]></description>
        	        	<pubDate>Wed, 09 Sep 2009 13:37:52 +0300</pubDate>
        </item>
</channel>
</rss>