<?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>danieleveratti.com</title>
	<atom:link href="http://www.danieleveratti.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.danieleveratti.com</link>
	<description>Italian programmers and sysadmins...do it best!</description>
	<lastBuildDate>Mon, 01 Mar 2010 11:01:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Read a Drive Serial Number in Visual Basic .NET</title>
		<link>http://www.danieleveratti.com/?p=114</link>
		<comments>http://www.danieleveratti.com/?p=114#comments</comments>
		<pubDate>Mon, 01 Mar 2010 10:57:32 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[drive serial number]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=114</guid>
		<description><![CDATA[I needed to do it for a windows application I&#8217;m writing. My problem was to get the current serial number windows provides when a drive is formatted. You know, the one that appears when you type the &#8220;dir&#8221; command in a ms-dos prompt window. I googled around but I found only code for VB6 or [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to do it for a windows application I&#8217;m writing. My problem was to get the current serial number windows provides when a drive is formatted. You know, the one that appears when you type the &#8220;dir&#8221; command in a ms-dos prompt window. I googled around but I found only code for VB6 or code which should not have worked in a console application.<br />
No default .NET object was giving me the piece of information I needed, so I though to get It directly from the &#8220;dir&#8221; command.<br />
I got how to launch a process and get its output from <a href="http://www.eggheadcafe.com/community/aspnet/14/13614/how-to-capture-execution.aspx">EggHeadCaf&egrave;</a> but I added some work by me.<br />
<span id="more-114"></span><br />
Calling directly the &#8220;dir&#8221; command didn&#8217;t work. But adding it as paramater to the &#8220;cmd&#8221; command gave no problem (complete command is &#8220;cmd /C dir&#8221;). This has been tested on an italian window xp professional. Let me know please if it has problems on other countries versions. According to the output of the &#8220;dir&#8221; command an English version of Windows 7 Ultimate, it should work.</p>
<p>Here is the code. Hope this can Help.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">    <span style="color: #000080;">Function</span> getHDSerial() <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
        <span style="color: #000080;">Dim</span> dir_cmd <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> Process
        dir_cmd.StartInfo.UseShellExecute = <span style="color: #000080;">False</span>
        dir_cmd.StartInfo.RedirectStandardOutput = <span style="color: #000080;">True</span>
        dir_cmd.StartInfo.RedirectStandardError = <span style="color: #000080;">True</span>
        dir_cmd.StartInfo.CreateNoWindow = <span style="color: #000080;">True</span>
        dir_cmd.StartInfo.FileName = <span style="color: #800000;">&quot;cmd&quot;</span>
        dir_cmd.StartInfo.Arguments = <span style="color: #800000;">&quot;/C dir&quot;</span>
        dir_cmd.Start()
        <span style="color: #000080;">Dim</span> <span style="color: #000080;">output</span> <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
        dir_cmd.StandardOutput.ReadLine() <span style="color: #008000;">' Discard first line
</span>        <span style="color: #000080;">output</span> = dir_cmd.StandardOutput.ReadLine <span style="color: #008000;">' second line should contain the serial number
</span>        <span style="color: #000080;">Dim</span> splitted() <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
        splitted = <span style="color: #000080;">output</span>.Split(<span style="color: #800000;">&quot;:&quot;</span>)
        <span style="color: #000080;">output</span> = splitted(1).Trim()
        Return <span style="color: #000080;">output</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=114</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Php On The Road Framework &#8211; near to first *alpha* release</title>
		<link>http://www.danieleveratti.com/?p=103</link>
		<comments>http://www.danieleveratti.com/?p=103#comments</comments>
		<pubDate>Wed, 23 Dec 2009 02:10:45 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHP On The Road]]></category>
		<category><![CDATA[phpontheroad]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=103</guid>
		<description><![CDATA[I always sayd that one of my aims was to develop an &#8220;important&#8221; framework to make PHP work like Ruby On Rails. The first alpha/unstable/use-at-your-own-risk version will be probably released in the first months of 2010. You know&#8230;I have to work, so my experiments are done during my freetime (especially at night&#8230;). So if you [...]]]></description>
			<content:encoded><![CDATA[<p>I always sayd that one of my aims was to develop an &#8220;important&#8221; framework to make PHP work like Ruby On Rails. The first alpha/unstable/use-at-your-own-risk version will be probably released in the first months of 2010. You know&#8230;I have to work, so my experiments are done during my freetime (especially at night&#8230;). So if you appreciate my &#8220;second&#8221; job as a web development researcher you can contact me for a donation via PayPal. But now let&#8217;s talk about PhpOnTheRoad, my new PHP framework!<br />
<span id="more-103"></span><br />
Basically PhpOnTheRoad (POTR) let&#8217;s you easily develop your web-app writing less code as possibile, being inspired from RubyOnRails. IMHO web sites always do the same things.<br />
Generally in a web site you can find:<br />
- some products or a catalog of products, divided into categories and sub-categories, with images, attachments and so on&#8230;<br />
- users: almost the 95% percent, I think, of the websites on the internet have some &#8220;register&#8221; button which allow the user to receive newsletters and/or to access some contents unavailable to not registered users.<br />
- some generic contents, which can be pages, files, links to other resources and so on<br />
- e-commerce: many web sites allow registered users to buy something, paying using credit card and receive what they bought at home</p>
<p>The aim of my PhpOnTheRoad framework isn&#8217;t do this things for you, but let you do them in almost half the time or less.</p>
<p>The basic idea of the PhpOnTheRoad framework is that you have to &#8220;describe&#8221; the contents you are going to edit. I&#8217;ll show you an example of usage, which is very clear.<br />
Think about the classical user registration. We need something called &#8220;User&#8221; (maybe a class?) to handle users&#8217; registrations on our web site and store users&#8217; data in a DBMS.<br />
There are always the same field, like username, email, password, etc.<br />
In POTR you can create a class User which extends the framework provided class ActiveArray:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #000000; font-weight: bold;">extends</span> ActiveArray <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;users&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">,</span>AA_INTEGER_PRIMARY_KEY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;first_name&quot;</span><span style="color: #339933;">,</span>AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;last_name&quot;</span><span style="color: #339933;">,</span> AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;address&quot;</span><span style="color: #339933;">,</span> AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;city&quot;</span><span style="color: #339933;">,</span>AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;avatar&quot;</span><span style="color: #339933;">,</span> AA_IMAGE_WITH_THUMB<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;email&quot;</span><span style="color: #339933;">,</span> AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">,</span> AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addAccessor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password_confirmation&quot;</span><span style="color: #339933;">,</span> AA_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is what is called model. It takes some inspiration from RoR&#8217;s models, but I think I have done something better. This extends the ActiveArray class, whose functionality is similar to RoR&#8217;s ActiveRecord, but it creates an object that gives you back an array, using them find($id_to_find) method. I choose this way, because I think php developers are more used to work with arrays and hashes than objects.<br />
Functions and methods like mysql_fetch_array() or MDB2::queryRow() (from PEAR) give you back arrays as default.</p>
<p>So we described how the entity &#8220;User&#8221; is composed. In your POTR Controller you just have to write something like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> UsersController <span style="color: #000000; font-weight: bold;">extends</span> ApplicationController <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> docreate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$user</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>create<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>V<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getData<span style="color: #009900;">&#40;</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></div></div>

<p>The POTR framework will do all the dirty work for inserting images and handling password. This example is very minimalist, there is no check on the inserted data and there are no validations: e.g an image should be an image and password should match its confirmation. They haven&#8217;t been implemented yet (maybe this is one of the reasons it&#8217;s still unstable and unreleased???) but they will be soon included, letting you also define your custom validations, which will be run before the insertion of the record into the database. But it will create the record, upload images and creating thumbs for them!!! No extra programming required!</p>
<p>What about HTML? We need only few lines to get this thing work&#8230;oops only one. You should create a view and name it as the controller function (in our example docreate.php) and put it in the right directory.<br />
Just add this line to the docreate.php file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?<span style="color: #339933;">=</span>auto_form_for<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">V</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;/users/docreate&quot;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>And your almost done. A new shining form is on your browser! What do you think about PHP On The Road? Isn&#8217;t it a lovely framework (or almost it will be)? I think my new framework will be second only to few other web development frameworks. My aims include to integrate ajax and some nice stuff like mootools and ReMooz. Any advice, suggestion, thought or else is well accepted. Please let me know!</p>
<p>Obviously all these contents can change before the first release, but these are the main ideas I want to put in Php On The Road.<br />
Thanks for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=103</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby 1.9.1 &#8211; gem install fcgi fails &#8230; FIXED!</title>
		<link>http://www.danieleveratti.com/?p=86</link>
		<comments>http://www.danieleveratti.com/?p=86#comments</comments>
		<pubDate>Mon, 26 Oct 2009 00:14:48 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[fcgi]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby 1.9.x]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=86</guid>
		<description><![CDATA[Hi all&#8230;first I wold thank all the people which are visiting and leaving comments on this blog!
I&#8217;m currently working on a Ruby On Rails project for the company where I work. According to my company&#8217;s bosses decisions all projects have to be developed on a testing server and then switch the project to a production [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all&#8230;first I wold thank all the people which are visiting and leaving comments on this blog!</p>
<p>I&#8217;m currently working on a Ruby On Rails project for the company where I work. According to my company&#8217;s bosses decisions all projects have to be developed on a testing server and then switch the project to a production system. Tomorrow I have to prepare the &#8220;production&#8221; system for my RoR project. So I said to myself: &#8220;Please don&#8217;t go to the server farm without knowing exactly what to do&#8221;. I took an old Fujitsu Notebook (with Japanese keyboard) and installed Debian 5.0.<br />
<span id="more-86"></span> So I started installing ruby and Ruby On Rails, with all the packages I need, including MySQL server and Apache Httpd 2.2. Something is very easy:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># apt-get install mysql-server</pre></div></div>

<p>Then I installed Ruby 1.9.1 instead of Ruby 1.8.7 or 1.9.0 that the default for Debian 5&#8217;s apt-get repositories.<br />
I wanted the newest and the stablest. So simple as saying configure, make, make install. But started the headache. Once installed all the libraries I needed to make my project work, I had to install the fcgi ruby gem in order to let it work with apache as fastcgi. But</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># gem install fcgi</pre></div></div>

<p> was giving me an error compiling it!!! But it wasn&#8217;t caused of missing libraries, it said was the code of gem to be wrong!!! I googled around to solve this problem. I&#8217;ve found that was a bug known since 2007 and it still was unsolved. The solution was to modify the source of the fcgi.c file contained in the fcgi-0.8.7 gem.<br />
I coldn&#8217;t find an already modified gem, so thanks to <a href="http://blog.rubyists.com/2009/06/02/ruby-fcgi-on-1-9-x">Deathsyn&#8217;s post on Rubyist</a> I made the modified gem.<br />
The steps were:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># gem unpack fcgi-0.8.7.gem   // unpack the gem
# cd fcgi-0.8.7/ext/fcgi  // go into source folder
# vim fcgi.c  // modfy gem
# ruby extconf.rb // configure the gem
# make  // compile it
# make install // install it!!!</pre></div></div>

<p>Et voilà it worked!!! Now I want to share this gem with you all. Hope this can help. I&#8217;m I couldn&#8217;t make a real gem. It&#8217;s a sort of &#8220;zip&#8221; package to compile and install. <a href="http://www.danieleveratti.com/downloads/fcgi-0.8.7-patched-for-ruby-1.9-Deathsyn-danieleveratti.com.zip">Download the &quot;gem&quot; package here!!!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=86</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mini How To: install RadRails on Eclipse without Aptana Studio? Yes we can</title>
		<link>http://www.danieleveratti.com/?p=82</link>
		<comments>http://www.danieleveratti.com/?p=82#comments</comments>
		<pubDate>Fri, 07 Aug 2009 11:40:10 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[IDE Configurations]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Aptana]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[RadRails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=82</guid>
		<description><![CDATA[RadRails is a powerful IDE for RubyOnRails development...but it's integrated in Aptana Studio which is very slow!!! I'd want to install RadRails on Eclipse without installing entire Aptana Studio...here is the solution!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve tryed it&#8230;Aptana Studio is a great IDE for web development, I used it a lot with PHP&#8230;but had a great problem wich lead me to use TextMate instead. Aptana Studio can become very very slow during its startup. It is because it tries to index all your file of all your open projects. I always have more than 10 projects in my Eclipse IDE (on whom Aptana Studio is designed) and the time to wait for Aptana Studio to let me work was awful. I returned to PHPEclipe plugin for Eclipse,Netbeans or TextMate, swiching them just in case of my programming needs. But now I need something for Ruby On Rails. Ok i can use TextMate, but I also want to use RadRails installed above my Eclipse Galileo&#8230;but RadRails is now integrated in Aptana Studio! And there seems not to be a link to install it as Eclipse plugin&#8230;<br />
<span id="more-82"></span><br />
So I sayid to myself: &#8220;someone should have done this before!&#8221; and Google told me : check <a href="http://satisheerpini.blogspot.com/2008/05/installing-radrails-on-eclipse.html">Satish&#8217;s Blog</a>.<br />
He gave me the answer for older Eclipse. Now I want to Integrate his tutorials with the new features for Eclipse Galileo and new urls.</p>
<p>First start your Eclipse IDE. From the Help menu select &#8216;Install new software&#8230;&#8217;. It will open a new window for installing remote and local packages. Click on the &#8216;Add&#8230;&#8217; button on the right to add 2 new update sites. </p>
<p>First you should install RDT (Ruby Development Tools). So add the this update site:<br />
Name: RDT<br />
Location: http://update1.aptana.org/rdt/3.2</p>
<p>Uncheck &#8216;Group items by category&#8217; and Eclipse will show a new package to install (Ruby Development Tools). Select it and then click &#8216;Next&#8217; to continue the installation and follow the normal installation instruction that will appear on the screen.<br />
Once installed you&#8217;ll be asked to restart Eclipse.</p>
<p>Once restarted you should go another time in Help->Install new software&#8230; and add a new update site:</p>
<p>Name: RadRails<br />
Location: http://radrails.sourceforge.net/update</p>
<p>Check the &#8216;RadRails&#8217; package and click &#8216;Next&#8217;. Wait for download and installation to complete&#8230;and voilà RadRails is now installed without installing AptanaStudio.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=82</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>RemoteSaneX &#8211; A java front-end for network saned scanners</title>
		<link>http://www.danieleveratti.com/?p=76</link>
		<comments>http://www.danieleveratti.com/?p=76#comments</comments>
		<pubDate>Tue, 23 Jun 2009 23:30:38 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=76</guid>
		<description><![CDATA[I think there are many good programs to manipulate and acquire images from saned scanners.
But I had some trouble in my network configuration. I have a linux debian server which I use as a print server and samba server for some small backup for stuff I seldom use. So why don&#8217;t use it also as [...]]]></description>
			<content:encoded><![CDATA[<p>I think there are many good programs to manipulate and acquire images from saned scanners.</p>
<p>But I had some trouble in my network configuration. I have a linux debian server which I use as a print server and samba server for some small backup for stuff I seldom use. So why don&#8217;t use it also as a scanner server?<br />
<span id="more-76"></span><br />
I got it, installed and configured SaneD an it worked. With my Windows XP stations I used TwainSane, which IMHO is a good program, at least it does what it promises. But on my MacbookPro? I&#8217;ve tried Snac, which works (i think) only for saned scanners attached to the mac (I&#8217;m not sure, but I think network is not supported).</p>
<p>Maybe there are many other programs to do the job. But I decided to write my own Remote Sane interface for image acquiring, to use it on my mac. But why don&#8217;t make it compatible to other operating systems? That&#8217;s a good idea, so I chose to write this program in Java. It will be open-source (or free-software if you prefer) and it uses some libraries called JSane which provide a saned server connection using saned&#8217;s native protocol. Today RemoteSaneX is born.</p>
<p>I hope someone shall find it useful. Please tell me if continue its development or if I have to give it up soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=76</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP On The Road Framework&#8230;work in progress</title>
		<link>http://www.danieleveratti.com/?p=73</link>
		<comments>http://www.danieleveratti.com/?p=73#comments</comments>
		<pubDate>Tue, 10 Mar 2009 23:34:35 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[nighty-build]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHP On The Road]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=73</guid>
		<description><![CDATA[I always wanted to develop a PHP framework similar to Ruby On Rails&#8230;so some time ago I started this project. When I started its development I wrote PHP4 compatible code, but now I think this framework should be at least PHP5 compatible. Probably a PHP 6 compatible version will be the next step after 1.0 [...]]]></description>
			<content:encoded><![CDATA[<p>I always wanted to develop a PHP framework similar to Ruby On Rails&#8230;so some time ago I started this project. When I started its development I wrote PHP4 compatible code, but now I think this framework should be at least PHP5 compatible. Probably a PHP 6 compatible version will be the next step after 1.0 release.</p>
<p>So I started writing it for PHP5 but I was never satisfied of my work, so I didn&#8217;t release the framework (early versions lack of generators,migrations and test suites) .</p>
<p>Now I feel a first nighty-build release of my PHP framework will come out very soon, so stay tuned.<br />
It will be only MySQL and MySQLi compatible, full support for Postrgres, Oracle, MS-SQL and other DBMS will be added later.</p>
<p>Here are the System Requirements and the features I&#8217;m developing</p>
<p>**** SYSTEM REQUIREMENTS ****<br />
I won&#8217;t tell you about the hardware. Needed to be installed a Web Server (e.g. Apache) and PHP 5.<br />
PHP need to come with some PEAR packages installed. First of all MDB2 and MDB2#mysql (or MDB2#mysqli).<br />
Needless to say that MySql and MySqli extensions have to be loaded in your php.ini</p>
<p>**** DEVELOPED FEATURES ****<br />
- Migrations: mysql and mysqli migrations are supported<br />
- ActiveRecord: easy to use and smart ActiveRecord implementation started. It uses MDB2 to access database.</p>
<p>**** STILL ON WORK FEATURES ****<br />
- Controllers implementation and generator<br />
- Models generator<br />
- Helpers (e.g. Forms auto-builder,  and stuff like this)<br />
- Engines (the way the framework rewrites URLS)<br />
- Template Engine</p>
<p>Some words about the Template Engine. I think I will use Smarty as the base template engine. Please let me know if you prefer other template engines or if I should write a new one from scratch (an .rhtml complatible template engine?). Needless to say it will be the last thing I will develop, so design ideas are well accepted!!!</p>
<p>I&#8217;d like also know how many people are still using PHP4 and need a PHP4 compatible framework. If there are many, I will think about doing it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=73</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jangol, PHP Content Management System&#8230;work started!!!</title>
		<link>http://www.danieleveratti.com/?p=69</link>
		<comments>http://www.danieleveratti.com/?p=69#comments</comments>
		<pubDate>Thu, 05 Mar 2009 10:33:04 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[jangol]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=69</guid>
		<description><![CDATA[Last week, I was following Software Design lessons at my university. While the professor was explaining why good design is important for building good software, I started to dream the solution of my problems. If I have to build a simple web site, what do I need? Something between Joomla and Wordpress.
I think Joomla is [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I was following Software Design lessons at my university. While the professor was explaining why good design is important for building good software, I started to dream the solution of my problems. If I have to build a simple web site, what do I need? Something between Joomla and Wordpress.</p>
<p>I think Joomla is not so easy to manage, while Wordpress is too simple. Obviously they are 2 differents thing with diffrent purposes. I&#8217;d like to know what dow you think about creating Jangol. Should I continue? Should I stop? Does someone already did something better? Which features should Jangol include? Please Help me&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=69</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>International visitors</title>
		<link>http://www.danieleveratti.com/?p=58</link>
		<comments>http://www.danieleveratti.com/?p=58#comments</comments>
		<pubDate>Wed, 18 Feb 2009 09:38:33 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=58</guid>
		<description><![CDATA[I&#8217;m receiving lots of comments written in Russian. I don&#8217;t know if they&#8217;re spam or not. Of Course I can&#8217;t check the content (I&#8217;m not able to read and understand Russian and other non-latin alphabet languages).
So if you want to post some comment, please write it in a language I can understand (English or Italian). [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m receiving lots of comments written in Russian. I don&#8217;t know if they&#8217;re spam or not. Of Course I can&#8217;t check the content (I&#8217;m not able to read and understand Russian and other non-latin alphabet languages).<br />
So if you want to post some comment, please write it in a language I can understand (English or Italian). Every comment written in an another language will be considered as SPAM.</p>
<p>Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=58</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Record Implementation in PHP? We need it&#8230;</title>
		<link>http://www.danieleveratti.com/?p=63</link>
		<comments>http://www.danieleveratti.com/?p=63#comments</comments>
		<pubDate>Sat, 03 Jan 2009 18:04:24 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=63</guid>
		<description><![CDATA[One of the more powerful features of the Ruby On Rails framework is the implementation of the ActiveRecord pattern. It provides the basic database operations (CRUD, Create Read Update Delete) in order to have fun in programming and not writing all the same boring SQL queries.
ActiveRecord implementation is quite complex in RubyOnRails. Let&#8217;s see an [...]]]></description>
			<content:encoded><![CDATA[<p>One of the more powerful features of the Ruby On Rails framework is the implementation of the ActiveRecord pattern. It provides the basic database operations (CRUD, Create Read Update Delete) in order to have fun in programming and not writing all the same boring SQL queries.</p>
<p>ActiveRecord implementation is quite complex in RubyOnRails. Let&#8217;s see an &#8220;easier&#8221; implementation in PHP. We should come to a very powerful version in some episodes.So stay tuned!<br />
<span id="more-63"></span><br />
The basic concept about ActiveRecord is that every record of a table is an object. Primarly we have to define a base class to provide database access. For the sake of semplicity we user the PEAR::MDB2 class in order to give basic database access.<br />
[ATTENTION: the following part of my article is written in Italian, I will translate it to English versi soon.]<br />
[The italian version of this article can be found at <a href="http://www.ciarpame.com">Ciarpame.com</a>]</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'MDB2.php'</span><span style="color: #339933;">;</span>
abstract <span style="color: #000000; font-weight: bold;">class</span> ActiveRecordBase <span style="color: #009900;">&#123;</span>
protected <span style="color: #000088;">$__db</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Dichiariamo un oggetto &quot;protected&quot; per l'accesso al DB</span>
protected <span style="color: #000088;">$__primary_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Definiamo una chiave primaria per la tabella. Può essere poi</span>
<span style="color: #666666; font-style: italic;">// modificata per ogni singola classe che estende questa.</span>
protected <span style="color: #000088;">$__fields</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// In questo attributo di tipo array andremo a salvare i campi della nostra tabella (escluso il campo primary key)</span>
protected <span style="color: #000088;">$__table</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// In questo attributo salviamo il nome della tabella</span>
<span style="color: #009933; font-style: italic;">/**
* Il costruttore istanzia una connessione con il db e se sono presenti dei dati
* li salva nell'oggetto (non nel database!)
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>MDB2<span style="color: #339933;">::</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span>DB_DSN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// DB_DSN è una stringa che contiene di dati accesso al DB</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__table <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">get_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fields</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
* Definiamo un metodo per create un nuovo Record.
* Esso è privato perché verrà utilizzato dal metodo save()
*/</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// Creaimo l'istruzione SQL a partire dai campi disponibili</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">quoteIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; (&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__fields <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$first</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">quoteIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$field</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;) VALUES (&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fields</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;?&quot;</span> <span style="color: #b1b100;">else</span> <span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;,?&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">:=</span><span style="color: #0000ff;">&quot;);&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$prep</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$prep</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pkey_field</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__primary_key<span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$pkey_field</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastInsertID</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$res</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">quoteIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__table<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; SET &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__fields <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$first</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$field</span> = ?&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$field</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$pkey_field</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__primary_key<span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;WHERE &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">quoteIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pkey_field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; = &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$pkey_field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$prep</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$prep</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> delete<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$pkey_field</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__primary_key<span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DELETE FROM &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">quoteIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__table<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">&quot; WHERE &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">quoteIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pkey_field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; = &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$pkey_field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__db<span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$pkey_field</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__primary_key<span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$pkey_field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> destroy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$pkey_field</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__primary_key<span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$pkey_field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In questa implementazione, ancora in stato &#8220;embrionale&#8221;, è possibile creare un nuovo record.<br />
Un uso molto semplice potrebbe essere creare una classe che estenda la base e istanziarne un oggetto:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'ActiveRecordBase.class.php'</span>
<span style="color: #000000; font-weight: bold;">class</span> Dog <span style="color: #000000; font-weight: bold;">extends</span> ActiveRecordBase <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$dog</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Dog<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;">'Pluto'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'age'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'7'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Il precedente script inserisce un nuovo record in una tabella &#8216;dog&#8217; (stessa nome della classe che estende ActiveRecordBase) assegnando gli attributi &#8216;name&#8217; e &#8216;age&#8217;.<br />
La primary key viene implicitamente impostata come &#8220;id&#8221; (ovviamente se il campo ha l&#8217;attributo auto_increment) e il valore inserito automaticamente.<br />
Il tutto in 3 righe di codice, molto molto semplici&#8230;non è una bella comodità?<br />
Più avanti vedremo come effettuare ricerche, e quindi come implementare il metodo &#8220;find&#8221; e migliorare ulteriormente la classe base in modo da gestire meglio errori, validazioni e chiavi esterne.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=63</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merry Christmas</title>
		<link>http://www.danieleveratti.com/?p=60</link>
		<comments>http://www.danieleveratti.com/?p=60#comments</comments>
		<pubDate>Wed, 24 Dec 2008 12:42:02 +0000</pubDate>
		<dc:creator>Daniele Veratti</dc:creator>
				<category><![CDATA[Info & Others]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.danieleveratti.com/?p=60</guid>
		<description><![CDATA[My personal Xmas greetings to all readers of this blog...what would You like as a present? I have an idea...]]></description>
			<content:encoded><![CDATA[<p>Only few hour to Christmas here in Italy. Greetings to everybody visits my Blog and web-site.</p>
<p>What are you going to ask to Santa Claus as a present? A new version of PHP? New MySQL? A new PHP Framework?</p>
<p>If your wishes are some of these you can believe Santa actually exists! A new version of Generally Available MySQL has arrived only about a month ago (5.1). PHP is going to bring to the public new versions of PHP&#8230;the 5.2 trunk is at revision 8 (5.2.8). I think they soon should put out a generally available version of PHP 5.3, the first supporting namespaces. Sincerely, I don&#8217;t think they will make a 5.2.83 version of PHP. They should stop before revision 20. Best if they stop before 10 (PHP 4.4 stopped at revision 9).</p>
<p>What about a new PHP framework? I&#8217;m currently developing it, probably I will use it in my last degree discussion.<br />It is called PhpOnTheRoad. It aims to be an implementation of the RubyOnRails framework. I think after my degree is taken (hope a 110 &amp; lode as final grade, the maximum in Italy) it will be generally available to the public.</p>
<p>Please let me know what would you find in this framework (think of what you dislike about RoR and why you love it).<br />Help for future versions is well accepted. Please send me an email to contactNO@SPAMdanieleveratti.com (you know what to delete&#8230;) or try to leave a comment to this post.</p>
<p>Merry XMAS (or Christmas if u prefer) to Everybody!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danieleveratti.com/?feed=rss2&amp;p=60</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
