<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Database Portability (Parts 1 and 2)</title>
	<atom:link href="http://paul-m-jones.com/archives/126/feed" rel="self" type="application/rss+xml" />
	<link>http://paul-m-jones.com/archives/126?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=database-portability</link>
	<description>It&#039;s not enough to be smart; you have to actually know things.</description>
	<lastBuildDate>Wed, 16 May 2012 17:27:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: capi</title>
		<link>http://paul-m-jones.com/archives/126/comment-page-1#comment-20568</link>
		<dc:creator>capi</dc:creator>
		<pubDate>Thu, 15 Dec 2005 13:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=126#comment-20568</guid>
		<description>Travis I believe the correct thing to do is to build the tables like normal and then add an extra field for storing the object.

However if you really want to do it your way a possible workaround is to add a meta field you can use for ordering, if one field doesn&#039;t solve the complexity you could build a seperate table that contains structure for each different type and have your table just be a masterrecord of all info...

Like for a tree struc...
http://fungus.teststation.com/~jon/treehandling/TreeHandling.htm

Doing this with a OR/M might be a good idea depending on preformance. So now instead of searching the masterrecord your searching a path and you hook up a callback in the OR/M record to pull objects as their needed? If any record is needed right away you could also do a JOIN or something...

just a thought, nobody will probably read this... the internet gobbles up more of my words. :D</description>
		<content:encoded><![CDATA[<p>Travis I believe the correct thing to do is to build the tables like normal and then add an extra field for storing the object.</p>
<p>However if you really want to do it your way a possible workaround is to add a meta field you can use for ordering, if one field doesn&#8217;t solve the complexity you could build a seperate table that contains structure for each different type and have your table just be a masterrecord of all info&#8230;</p>
<p>Like for a tree struc&#8230;<br />
<a href="http://fungus.teststation.com/~jon/treehandling/TreeHandling.htm" rel="nofollow">http://fungus.teststation.com/~jon/treehandling/TreeHandling.htm</a></p>
<p>Doing this with a OR/M might be a good idea depending on preformance. So now instead of searching the masterrecord your searching a path and you hook up a callback in the OR/M record to pull objects as their needed? If any record is needed right away you could also do a JOIN or something&#8230;</p>
<p>just a thought, nobody will probably read this&#8230; the internet gobbles up more of my words. :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis Swicegood</title>
		<link>http://paul-m-jones.com/archives/126/comment-page-1#comment-5669</link>
		<dc:creator>Travis Swicegood</dc:creator>
		<pubDate>Wed, 06 Apr 2005 19:53:27 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=126#comment-5669</guid>
		<description>As I refractor this in my head I&#039;m seeing the possible issue - searching for ranges.  Unless you create some method for storing the object inside a table unto itself (i.e. DateObj in DateObj-Table) - it wouldn&#039;t be feasible.  Even thing, the complexity could easily get out of hand.

Now if you had a table that could take a class construct via ReflectionClass and automatically create a table to break the object apart and store it.  You would almost have to build a query language to handle searching though.  Something like new SerializedSearch(&#039;DateObj&#039;, &#039;year = &quot;2005&quot;&#039;);

It could all work, just one of those &quot;would it really be useful&quot; things...   Still - it&#039;s interesting to think about :)</description>
		<content:encoded><![CDATA[<p>As I refractor this in my head I&#8217;m seeing the possible issue &#8211; searching for ranges.  Unless you create some method for storing the object inside a table unto itself (i.e. DateObj in DateObj-Table) &#8211; it wouldn&#8217;t be feasible.  Even thing, the complexity could easily get out of hand.</p>
<p>Now if you had a table that could take a class construct via ReflectionClass and automatically create a table to break the object apart and store it.  You would almost have to build a query language to handle searching though.  Something like new SerializedSearch(&#8216;DateObj&#8217;, &#8216;year = &#8220;2005&#8243;&#8216;);</p>
<p>It could all work, just one of those &#8220;would it really be useful&#8221; things&#8230;   Still &#8211; it&#8217;s interesting to think about :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis Swicegood</title>
		<link>http://paul-m-jones.com/archives/126/comment-page-1#comment-5667</link>
		<dc:creator>Travis Swicegood</dc:creator>
		<pubDate>Wed, 06 Apr 2005 19:39:49 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=126#comment-5667</guid>
		<description>That would be more prohibitive.  However, you could always construct your statements so the data in the WHERE clause is serialize()&#039;d prior to send it to the database server.

$stmt = sprintf(&#039;SELECT name FROM table WHERE date = &quot;%s&quot;&#039;,
  $dao-&gt;escape($dateObj-&gt;serialize()));

Of course, if you&#039;re using a builder of some sort to build the query for you, the code would be:

$stmt-&gt;addWhere($dateObj);

And $stmt-&gt;execute() would know that any thing added via addWhere() has a serialize() method - class hinting would be the thing here - require a Serializable interface in addWhere.  I may play around with this a bit more - sounds like it would be an interesting way to store data.  I&#039;m curious how much (if any) of a performance hit this would cause.</description>
		<content:encoded><![CDATA[<p>That would be more prohibitive.  However, you could always construct your statements so the data in the WHERE clause is serialize()&#8217;d prior to send it to the database server.</p>
<p>$stmt = sprintf(&#8216;SELECT name FROM table WHERE date = &#8220;%s&#8221;&#8216;,<br />
  $dao-&gt;escape($dateObj-&gt;serialize()));</p>
<p>Of course, if you&#8217;re using a builder of some sort to build the query for you, the code would be:</p>
<p>$stmt-&gt;addWhere($dateObj);</p>
<p>And $stmt-&gt;execute() would know that any thing added via addWhere() has a serialize() method &#8211; class hinting would be the thing here &#8211; require a Serializable interface in addWhere.  I may play around with this a bit more &#8211; sounds like it would be an interesting way to store data.  I&#8217;m curious how much (if any) of a performance hit this would cause.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pmjones</title>
		<link>http://paul-m-jones.com/archives/126/comment-page-1#comment-5661</link>
		<dc:creator>pmjones</dc:creator>
		<pubDate>Wed, 06 Apr 2005 17:01:48 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=126#comment-5661</guid>
		<description>Hi, Travis -- neat idea for storing objects, but not so hot if you want to do a select-by-date (or even an order-by-date) ... the serialized object, while *very* useful once unserialized by PHP, is not that useful when constructing SQL statements.  But storing prefs that way, perhaps with some query-able fields as hinting, is pretty cool.  :-)</description>
		<content:encoded><![CDATA[<p>Hi, Travis &#8212; neat idea for storing objects, but not so hot if you want to do a select-by-date (or even an order-by-date) &#8230; the serialized object, while *very* useful once unserialized by PHP, is not that useful when constructing SQL statements.  But storing prefs that way, perhaps with some query-able fields as hinting, is pretty cool.  :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis Swicegood</title>
		<link>http://paul-m-jones.com/archives/126/comment-page-1#comment-5659</link>
		<dc:creator>Travis Swicegood</dc:creator>
		<pubDate>Wed, 06 Apr 2005 16:53:21 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=126#comment-5659</guid>
		<description>Hey Paul.  I&#039;m writing a preference system where I&#039;m storing multiple types of values in a table with the following structure:

&lt;code&gt;CREATE TABLE prefs (
  key VARCHAR(50) NOT NULL,
  value VARCHAR(255) NOT NULL,
  owner_id INT);&lt;/code&gt;

Its similar to your straight text approach, except I&#039;m taking it one step further.  Prior to any data being stored in the value field, I&#039;m running it through serialize().  You could take the same approach you&#039;re using and run the data through serialize(), then when you application unserialize()&#039;s it on the other end, it would be ready to use.  This becomes extremely useful when you&#039;re using an OO-approach.  Your datetime example above could come straight out of the database as a DateTime object of your creation.

Of course, that ties you down to PHP, but if that&#039;s where you&#039;re intending to use the data.  And I imagine it wouldn&#039;t be that difficult to write an unserialize() method to port it to other languages.</description>
		<content:encoded><![CDATA[<p>Hey Paul.  I&#8217;m writing a preference system where I&#8217;m storing multiple types of values in a table with the following structure:</p>
<p><code>CREATE TABLE prefs (<br />
  key VARCHAR(50) NOT NULL,<br />
  value VARCHAR(255) NOT NULL,<br />
  owner_id INT);</code></p>
<p>Its similar to your straight text approach, except I&#8217;m taking it one step further.  Prior to any data being stored in the value field, I&#8217;m running it through serialize().  You could take the same approach you&#8217;re using and run the data through serialize(), then when you application unserialize()&#8217;s it on the other end, it would be ready to use.  This becomes extremely useful when you&#8217;re using an OO-approach.  Your datetime example above could come straight out of the database as a DateTime object of your creation.</p>
<p>Of course, that ties you down to PHP, but if that&#8217;s where you&#8217;re intending to use the data.  And I imagine it wouldn&#8217;t be that difficult to write an unserialize() method to port it to other languages.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

