<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dom111.co.uk &#187; activerecord</title>
	<atom:link href="http://www.dom111.co.uk/blog/tag/activerecord/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dom111.co.uk/blog</link>
	<description>Move along. Nothing to see here.</description>
	<lastBuildDate>Wed, 14 Jul 2010 19:30:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>mod-framework: PHP, light and easy</title>
		<link>http://www.dom111.co.uk/blog/rambles/mod-framework-php-light-and-easy/39</link>
		<comments>http://www.dom111.co.uk/blog/rambles/mod-framework-php-light-and-easy/39#comments</comments>
		<pubDate>Thu, 13 Nov 2008 14:16:45 +0000</pubDate>
		<dc:creator>dom111</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rambles]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[convention over configuration]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[model view controller]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.dom111.co.uk/blog/?p=39</guid>
		<description><![CDATA[I know there&#8217;s already infinite PHP framework out there, trying to be rails; and most of them are doing it really well, I just feel that none of them completely embrace the simplicity of convention over configuration, so I&#8217;m trying to build one that ticks all the boxes. It&#8217;s pretty simple so far, and is [...]]]></description>
			<content:encoded><![CDATA[<p>I know there&#8217;s already infinite PHP framework out there, trying to be rails; and most of them are doing it really well, I just feel that none of them completely embrace the simplicity of convention over configuration, so I&#8217;m trying to build one that ticks all the boxes.</p>
<p>It&#8217;s pretty simple so far, and is only a few hundred KB, but I think it&#8217;s got some cool features, and maybe even potential.</p>
<p>Like the other stuff it&#8217;s under a Creative-Commons SA license and can be found at:</p>
<p><a href="http://mod-framework.googlecode.com/">http://mod-framework.googlecode.com/</a>.</p>
<p>Any opinions, suggestions, contributions would be gratefully received.</p>
<p>Current functionality:</p>
<p>Model-View-Controller system<br />
MySQL support (using a modified version of the DB class from earlier)<br />
script/server implementation in PHP<br />
Helper association, so if you create a PageHelper class for your Pages controller all the functions will automatically be made &#8216;global&#8217; (accessible view functionname() instead of Helper::functionname())<br />
Includes mootools in the htdocs folder</p>
<p>The DB doesn&#8217;t work quite how I would have imagined it to (well, with PHP 5.3 it might&#8230; but I haven&#8217;t got it yet&#8230;) so currently any models are added to $GLOBALS[] so that for a Page model, $GLOBALS['Page']-&gt;find_by_name(&#8216;dom&#8217;), etc would work.</p>
<p>There&#8217;s probably some other stuff in there too&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dom111.co.uk/blog/rambles/mod-framework-php-light-and-easy/39/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB</title>
		<link>http://www.dom111.co.uk/blog/coding/db/8</link>
		<comments>http://www.dom111.co.uk/blog/coding/db/8#comments</comments>
		<pubDate>Wed, 23 Jul 2008 22:50:01 +0000</pubDate>
		<dc:creator>dom111</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.dom111.co.uk/blog/?p=8</guid>
		<description><![CDATA[Here&#8217;s a little script I&#8217;ve wanted to make for a while, but have only just finally got the motivation to work on. It&#8217;s a lightweight Database wrapper with functions similar to Ruby on Rails&#8217; ActiveRecord. When I discovered the __call() method I wanted to make my own version in PHP, so here it is! It [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little script I&#8217;ve wanted to make for a while, but have only just finally got the motivation to work on.</p>
<p>It&#8217;s a lightweight Database wrapper with functions similar to Ruby on Rails&#8217; ActiveRecord.</p>
<p>When I discovered the __call() method I wanted to make my own version in PHP, so here it is!</p>
<p>It supports most basic functions, all based on the MySQL set of PHP functions, no other wrapper is required (PEAR etc.). There is not (yet?) any automatic mysql_real_escape_string or anything, although that could easily be added if required, my assumption is you&#8217;ve done that kind of thing already before passing anything to it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DB<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql://username:password@server:port/database'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$people</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'people'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$companies</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'companies'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$company</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$company</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find_by_name_like</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%test%'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$person</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$people</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Dom'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'company_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$company</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'created_date'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$people</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$people</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">print</span> <span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Dom</span>
&nbsp;
<span style="color: #b1b100;">print</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Dom</span>
&nbsp;
<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$person</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$new_users</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find_by_created_date_before</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 hour ago'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_users</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// loop through all the users with a create date more than 1 hour ago</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$company</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">company_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// and delete any that don't have a company associated with them</span>
    <span style="color: #000088;">$people</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>It&#8217;s only a first draft, so any comments, questions or pointing out any typo&#8217;s in the code, (yeah, there are likely to be a few&#8230;) would be muchly appreciated.</p>
<p>This work is free under the <a href="http://creativecommons.org/licenses/by-sa/2.0/uk/">Creative Commons Share Alike 2.0 license</a>.</p>
<p>Download:</p>
<p><a href="/files/DB/DB_0.1.tar.gz" title="Download DB_01.tar.gz">DB_0.1.tar.gz (4.84Kb)</a></p>
<p>Edit: Think next on my list is TextMate syntax highlighting and maybe the non-default template&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dom111.co.uk/blog/coding/db/8/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
