<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Forum posts to 'Archive'</title>
		<link>http://www.silverstripe.org/archive/rss</link>
		<atom:link href="http://www.silverstripe.org/archive/rss" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title>Re: secondary indices in tables</title>
			<link>http://www.silverstripe.org/archive/show/130870?start=0#post131322</link>
			<description>&lt;p&gt;After drilling down into Sapphire, I found some hints on this subject.  Evidently secondary indexes are already in sapphire, bug no examples seem to exist.  This snippet will force that one and only one item of 'Tag' exists for each Tagname. &lt;/p&gt;&lt;p&gt;Also the syntax for secondary keys is, well, not obvious.  &lt;br /&gt;$indexes = array('Bob' =&amp;gt; 'unique (Joe)');  -- gets mangled to 'UNIQUE BOB (JOE)' &lt;/p&gt;&lt;p&gt;&lt;div class=&quot;codesnippet&quot;&gt;&lt;p&gt;&amp;lt;?php&lt;/p&gt;&lt;p&gt;class Tag extends DataObject {&lt;br /&gt;        static $db = array ( 'Tag' =&amp;gt;'Varchar');&lt;br /&gt;        static $indexes = array ('Tag'=&amp;gt; 'unique (Tag) '  );&lt;br /&gt;        static $default_records = array ( array('Tag' =&amp;gt; 'vavavoom' ) );&lt;br /&gt;        static $belongs_many_many = array (&lt;br /&gt;                'Meets' =&amp;gt; 'Meet',&lt;br /&gt;                'Entries' =&amp;gt; 'Entry'&lt;br /&gt;                );&lt;br /&gt;        static function getTagByName ($name) {&lt;br /&gt;        $name = trim ( strtolower($name));&lt;br /&gt;        $me = DataObject::get_one('Tag',&quot;Tag = '$name'&quot;);&lt;br /&gt;        if (! $me) {&lt;br /&gt;                $me = new Tag();&lt;br /&gt;                $me -&amp;gt; Tag = $name;&lt;br /&gt;                $me -&amp;gt; write();&lt;br /&gt;                }&lt;br /&gt;        else { $me = new Tag($me-&amp;gt;record);&lt;br /&gt;                }&lt;br /&gt;        return  $me;&lt;br /&gt;        }&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;?&amp;gt;&lt;div class=&quot;codesnippet&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;Posted to: secondary indices in tables &lt;a href=&quot;http://www.silverstripe.org/archive/show/130870?start=0#post131322&quot;&gt;Show Thread&lt;/a&gt; | &lt;a href=&quot;http://www.silverstripe.org/archive/reply/130870?start=0#post131322&quot;&gt;Post Reply&lt;/a&gt;</description>
			<pubDate>Tue, 29 Jul 2008 15:27:18 +1200</pubDate>
			<dc:creator>jahbini</dc:creator>
			<guid>http://www.silverstripe.org/archive/show/130870?start=0#post131322</guid>
		</item>
		
		<item>
			<title>secondary indices in tables</title>
			<link>http://www.silverstripe.org/archive/show/130870#post130870</link>
			<description>&lt;p&gt;I need to create a dictionary of phrases.  Each phrase must be unique in the dictionary:  That is, it looks like an index to the table.  The phrase will have many-to-many relations with other classes in my whole site, and may be a real source of inefficiency unless speedy look up to insure uniqueness, etc.  (oh, yes, there will be potentially many, many thousands of these phrases)&lt;/p&gt;&lt;p&gt;At present I see no way to tell sapphire to create a second index, nor do I see an easy way to insert into an existing table and insure uniqueness.&lt;/p&gt;&lt;p&gt;I fear that I have looked in all the wrong places and am missing something pretty fundamental.  Is there an 'industry standard' method of generating secondary keys?  And insuring unique entries in a DB?&lt;/p&gt;&lt;br&gt;&lt;br&gt;Posted to: secondary indices in tables &lt;a href=&quot;http://www.silverstripe.org/archive/show/130870#post130870&quot;&gt;Show Thread&lt;/a&gt; | &lt;a href=&quot;http://www.silverstripe.org/archive/show/130870#post130870&quot;&gt;Post Reply&lt;/a&gt;</description>
			<pubDate>Mon, 28 Jul 2008 20:43:29 +1200</pubDate>
			<dc:creator>jahbini</dc:creator>
			<guid>http://www.silverstripe.org/archive/show/130870#post130870</guid>
		</item>
		

	</channel>
</rss>