<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://community.devpinoy.org/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Junrey Beduya</title><subtitle type="html" /><id>http://community.devpinoy.org/blogs/jbeduya/atom.aspx</id><link rel="alternate" type="text/html" href="http://community.devpinoy.org/blogs/jbeduya/default.aspx" /><link rel="self" type="application/atom+xml" href="http://community.devpinoy.org/blogs/jbeduya/atom.aspx" /><generator uri="http://communityserver.org" version="4.1.31106.3070">Community Server</generator><updated>2006-01-29T22:09:00Z</updated><entry><title>phptarsier-0.1.1pre-alpha release!</title><link rel="alternate" type="text/html" href="/blogs/jbeduya/archive/2006/03/06/phptarsier_2D00_0.1.1pre_2D00_alpha-release_2100_.aspx" /><id>/blogs/jbeduya/archive/2006/03/06/phptarsier_2D00_0.1.1pre_2D00_alpha-release_2100_.aspx</id><published>2006-03-06T10:35:00Z</published><updated>2006-03-06T10:35:00Z</updated><content type="html">&lt;h3&gt;Release Name: &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=153767"&gt;phptarsier 0.1.1pre-alpha&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;
&lt;/p&gt;&lt;b&gt;Notes:&lt;/b&gt;&lt;br&gt;This release was delayed in schedule due to some projects that I have to do first. Sorry for those who have anticipated this early.  &lt;br&gt;&lt;br&gt;This has been one of the major milestones in phptarsier releases. There has been some major changes from the previous release. Future releases will include the implementation of phpUnit test suite, other database implementations, script and code generators and anything possible.&lt;br&gt;&lt;br&gt;Enjoy this release.&lt;br&gt;&lt;hr&gt;&lt;br&gt;&lt;b&gt;Changes:&lt;/b&gt;&lt;br&gt;* introduction of Html class to organize Html functionalities such as text_fields, buttons, forms, etc.&lt;br&gt;* introducton of Ajax class that encapsulates the functionality of the prototype javascript library (http://prototype.conio.net)&lt;br&gt;* Effect class that implements the javascript functionality of script.aculo.us library (http://script.aculo.us)&lt;br&gt;* implementation of has_and_belongs_to_many in ActiveRecord&lt;br&gt;* implementation of belongs_to in ActiveRecord&lt;br&gt;* a change from "public static" to just "public" in the table_name() and primary_key() functions of ActiveRecord due to some implementation problems with PHP in static variables and functions&lt;br&gt;* minor bug fixes&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://community.devpinoy.org/aggbug.aspx?PostID=2052" width="1" height="1"&gt;</content><author><name>jbeduya</name><uri>http://community.devpinoy.org/members/jbeduya/default.aspx</uri></author></entry><entry><title>How ActiveRecord Works in phptarsier</title><link rel="alternate" type="text/html" href="/blogs/jbeduya/archive/2006/01/30/How-ActiveRecord-Works-in-phptarsier.aspx" /><id>/blogs/jbeduya/archive/2006/01/30/How-ActiveRecord-Works-in-phptarsier.aspx</id><published>2006-01-30T10:20:00Z</published><updated>2006-01-30T10:20:00Z</updated><content type="html">&lt;p&gt;It's Ruby on Rails, almost... &lt;br&gt;&lt;/p&gt;&lt;p&gt;
One of the great features about Ruby on Rails is its data model
implementation in the form of ActiveRecord. It's really impressive the
way it was implemented which really makes it promising. There has been
some attempts to port that feature into PHP but I was not able to see
an implementation that looks more like it.&lt;/p&gt;

&lt;p&gt;
In my attempt to create phptarsier, it was one of the things that I have to make sure it works closer to ActiveRecord in Rails.
&lt;/p&gt;

&lt;b&gt;Database Configuration&lt;/b&gt;

&lt;p&gt;
Before you run your application, you need to edit the config/config.php
file for you to get started. This will setup the database connection
for you and all your models will have the same connection as you
instantiate them.&lt;/p&gt;

&lt;b&gt;Data Model&lt;/b&gt;

&lt;p&gt;
Now you have setup your database connection, you need to setup your
models for your database. Models are like representations of database
tables. For example, if you have a table name "blogs", you would define
your model like the following: &lt;/p&gt;&lt;pre&gt;&amp;lt;?php&lt;br&gt;class Blog extends ActiveRecordBase {&lt;br&gt;	public function table_name() {&lt;br&gt;		return "blogs";&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	public function primary_key() {&lt;br&gt;		return "id";&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;
As a general rule for phptarsier models, you have to name the above
file as app/models/Blog.php. The file should represent the model,
always keep that in mind. If we create a model, we need to extend the
functionality of ActiveRecordBase class to enable our model to perform
the way we want it to do. All the methods and properties in
ActiveRecordBase class is now inherited by our model. You might have
notice that I have implemented two methods, namely: table_name() and
primary_key(). Actually, this overrides the same methods implemented in
our base class. Why I suggest you to create your model like this, is to
gain a little time. It is important for me, but if its not a great deal
for you, you may not declare the two methods. With the above
implementation, the table name and primary key are automatically
returned and the object will not have to gather its information by
querying the database. &lt;p&gt;&lt;/p&gt;

&lt;p&gt;Given that class, you can now perform the basic
CRUD(create-retrieve-update-delete) operations. The following are example
implementations.
&lt;br&gt;&lt;br&gt;
&lt;b&gt;CREATE an Entry&lt;/b&gt;
&lt;/p&gt;&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$Blog-&amp;gt;create(array(&lt;br&gt;	'title' =&amp;gt; 'My first blog',&lt;br&gt;	'author' =&amp;gt; 'jbeduya',&lt;br&gt;	'intro_text' =&amp;gt; 'An introduction to my first blog.',&lt;br&gt;	'body' =&amp;gt; 'The content of my first blog! Wow!'&lt;br&gt;));&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;

&lt;b&gt;UPDATE an Entry&lt;/b&gt;

&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$blog = $Blog-&amp;gt;find(1);&lt;br&gt;$blog-&amp;gt;title = "My First Blog's new title";&lt;br&gt;$blog-&amp;gt;save();&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;
The $Blog-&amp;gt;find(1) is then converted to some SQL statement that
looks like this: SELECT * FROM blogs WHERE id=1. With the given query
it returns an object that has all the fields for the blogs table. The
next statement, updates the title to some other value and then updates
the database with the changes. That's how easy it is. &lt;br&gt;&lt;br&gt;

&lt;b&gt;DELETE an Entry&lt;/b&gt;
&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$Blog-&amp;gt;find(1)-&amp;gt;delete();&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;
The above simply tells the object to query this row and delete it. That simple.&lt;p&gt;&lt;/p&gt;
&lt;br&gt;&lt;br&gt;
&lt;b&gt;Model Relationships&lt;/b&gt;
&lt;p&gt;
We are doing fine and we can now create models for each and every table
in our database. But what if we want to make some relationships our
models. As with my example, a blog has comments. First we need to
create our comment model that will look like the following:
&lt;/p&gt;&lt;pre&gt;&amp;lt;?php&lt;br&gt;class Comment extends ActiveRecordBase {&lt;br&gt;	public function table_name() {&lt;br&gt;		return "comments";&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	public function primary_key() {&lt;br&gt;		return "id";&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;How
are we gonna make that relationship, that every blog has many comments?
It is simple and it requires only a few lines of codes. We need to
update our Blog model to tell it has many comments. Our new Blog model
should have the following codes added:
&lt;pre&gt;&amp;lt;?php&lt;br&gt;....&lt;br&gt;class Blog extends ActiveRecordBase {&lt;br&gt;	public function __construct() {&lt;br&gt;		$this-&amp;gt;has_many('comments', array(&lt;br&gt;				t_class_name =&amp;gt; 'Comment',&lt;br&gt;				t_foreign_key =&amp;gt; 'blog_id',&lt;br&gt;				t_reference_key =&amp;gt; 'id'&lt;br&gt;			));&lt;br&gt;	}&lt;br&gt;	...&lt;br&gt;}&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;The
above code simply tells that each row of Blog has many "comments", as
specified in the first parameter. The first parameter seves as the
relationship to the model. The second parameter which is an array of
some contants with values are additional parameters required to
properly associate the given relationship. If we have to read it, blog
has many comments, to determine its comments you instantiate the class
named 'Comment' and check if the value for blog_id in 'Comment' is the
same as my id. With that specified, you can simply perform the
following query.
&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$blog = $Blog-&amp;gt;find(1);&lt;br&gt;$comments = $blog-&amp;gt;comments-&amp;gt;find_all();&lt;br&gt;while ($comment = $comments-&amp;gt;each()) {&lt;br&gt;	echo $comment-&amp;gt;comment;  // displays the comment itself.&lt;br&gt;}&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/pre&gt;The
"comments" property is automatically known by the class because of the
relationship that we specified. The above statment simply queries the
database for all the comments of the given blog.&lt;br&gt;&lt;br&gt;&lt;b&gt;find_by_&amp;lt;field(s)&amp;gt; and find_all_by_&amp;lt;field(s)&amp;gt;&lt;br&gt;&lt;/b&gt;&lt;br&gt;One of the new implementations of ActiveRecordBase is the use of find_by and find_all_by clause.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$blog = $Blog-&amp;gt;find_by_&lt;b&gt;title&lt;/b&gt;('How ActiveRecord Works in phptarsier');&lt;br&gt;echo $blog-&amp;gt;author;&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;/pre&gt;That should pretty simple. It queries the blogs table using the &lt;b&gt;title&lt;/b&gt; field. It could even take additional fields by adding more fields and separating it with an &lt;b&gt;_and_&lt;/b&gt;.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$blog = $Blog-&amp;gt;find_by_&lt;b&gt;title_and_author&lt;/b&gt;('How ActiveRecord Works in phptarsier', 'jbeduya');&lt;br&gt;echo $blog-&amp;gt;author;&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;/pre&gt;
Isn't that neat? How about the following:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&amp;lt;?php&lt;br&gt;...&lt;br&gt;$Blog = new Blog();&lt;br&gt;$blog = $Blog-&amp;gt;find_all_by_&lt;b&gt;author&lt;/b&gt;('jbeduya', array(t_condition =&amp;gt; 'title'));&lt;br&gt;echo $blog-&amp;gt;author;&lt;br&gt;...&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;


&lt;p&gt;Phew...&lt;/p&gt;&lt;p&gt;A new release is full-packed with new features:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;pjs (a phptarsier version of rjs)&lt;/li&gt;&lt;li&gt;ajax and effects&lt;/li&gt;&lt;li&gt;components&lt;/li&gt;&lt;li&gt;etc...&lt;/li&gt;&lt;/ul&gt;I am currently working for its site and sample applications. Just wait till it comes out, you can email me if you want an early copy of it. By the way I have changed its License from GPL to MIT.&lt;br&gt;&lt;br&gt;Enjoy.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://community.devpinoy.org/aggbug.aspx?PostID=1182" width="1" height="1"&gt;</content><author><name>jbeduya</name><uri>http://community.devpinoy.org/members/jbeduya/default.aspx</uri></author><category term="PHP" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/PHP/default.aspx" /><category term="phptarsier" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/phptarsier/default.aspx" /><category term="ActiveRecordBase" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/ActiveRecordBase/default.aspx" /><category term="PHP 5 Framework" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/PHP+5+Framework/default.aspx" /></entry><entry><title>phptarsier - a development framework</title><link rel="alternate" type="text/html" href="/blogs/jbeduya/archive/2006/01/29/Junrey-Beduya.aspx" /><id>/blogs/jbeduya/archive/2006/01/29/Junrey-Beduya.aspx</id><published>2006-01-30T06:09:00Z</published><updated>2006-01-30T06:09:00Z</updated><content type="html">&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;A Development Framework&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

&lt;b&gt;&lt;span&gt;phptarsier.about&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span&gt;
Welcome to &lt;strong&gt;phptarsier&lt;/strong&gt;! &lt;br /&gt;&lt;br /&gt; This is a quick overview on how &lt;strong&gt;phptarsier&lt;/strong&gt;
framework works. You will be guided through the features as well as the
structure for the framework. The information presented within this
guide might not be enough for you to get started. You may want to look
at Ruby on Rails as a reference. I really tried to make this framework
to look like Ruby on Rails.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

&lt;span&gt;As a developer, I really appreciate Ruby
as a language and Rails as a framework. It gives you an idea that you
can improve what you do everyday and I think that is what it give to
its developers. As a PHP Developer for quite sometime, I could see how
easy it is to develop an application within the Ruby on Rails
environment compared to the old-style development under PHP.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

&lt;span&gt;But there must be a reason or reasons
behind why not everybody would just jump into something great. For me,
one of the factors that I have considered and is really an impact for
me is its speed. As a web developer, I really want my application to be
fast so users won't have wait for sometime while clicking just a single
link. And PHP does best with speed, although the symantics for PHP
might not be a very well suited to produce such kind of library but I
try to make the simplest possible way for it to work.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

&lt;span&gt;I tried to look at &lt;a href="http://www.rubyonrails.org"&gt;Rails&lt;/a&gt; and I created something that looks like it and I named it "&lt;strong&gt;phptarsier&lt;/strong&gt;".
A small framework that gives the basic functionality of a Model View
Controller (MVC). Right now I have implemented the basic
functionalities for the framework and created a blog sample along with
its 0.1.0 release. You can check it out at &lt;a href="http://www.sourceforge.net/projects/phptarsier"&gt;SourceForge&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

&lt;b&gt;&lt;span&gt;phptarsier.structure&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span&gt;
The framework has the following structure:
&lt;pre&gt;- app&lt;br /&gt;  - controllers&lt;br /&gt;  - helpers&lt;br /&gt;  - models&lt;br /&gt;  - views&lt;br /&gt;    - default&lt;br /&gt;    - layouts&lt;br /&gt;- docs&lt;br /&gt;- config&lt;br /&gt;- lib&lt;br /&gt;  - eyes&lt;br /&gt;    - actionpack&lt;br /&gt;    - activerecord&lt;br /&gt;    - tarsier&lt;br /&gt;- public&lt;br /&gt;  - css&lt;br /&gt;  - img&lt;br /&gt;  - js&lt;br /&gt;- scripts&lt;br /&gt;&lt;/pre&gt;For
some developers who are not yet familiar with the structure, I am
afraid that I may not be able to discuss this in detail as of now. You
can still look for more reference at the Rails site.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

&lt;b&gt;&lt;span&gt;phptarsier.structure.app&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;

&lt;span&gt;
The &lt;strong&gt;app&lt;/strong&gt; folder contains several folders, namely: controllers, helpers, models, and views. This folder is the heart of your application.
You will be coding within this folder.
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;controllers&lt;/strong&gt; - contains all of the application controllers. Controller will handle most of your application operations.&lt;/li&gt;
 &lt;li&gt;&lt;strong&gt;helpers&lt;/strong&gt;
- are classes/functions that can help with the controller. Maybe that
is why it's called helper. :) As of 0.1.0, this is not yet implemented.&lt;/li&gt;
 &lt;li&gt;&lt;strong&gt;models&lt;/strong&gt;
- are representation of your database connection. Every table in your
database will require a model if you wanted to do something with it.&lt;/li&gt;
 &lt;li&gt;&lt;strong&gt;views&lt;/strong&gt; - contains the rendering for your application. Contains html codes, usually.&lt;/li&gt;
&lt;/ul&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;&lt;span&gt;phptarsier.structure.config&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;

&lt;span&gt;You will be needing to edit the files
within this folder. For database connections, edit config.php and
router.php for routing configuration. These are the only files that you
need to edit for you to get started. Never mind all the other folders
not mentioned for now.
&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span&gt;Get the sample blog and experiment with
it. You can make questions, comments, suggestions and/or feature
request at jbeduya@gmail.com. I don't accept solicitations though but I
accept donations. :) Have a nice php coding.
&lt;/span&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://community.devpinoy.org/aggbug.aspx?PostID=1123" width="1" height="1"&gt;</content><author><name>jbeduya</name><uri>http://community.devpinoy.org/members/jbeduya/default.aspx</uri></author><category term="PHP" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/PHP/default.aspx" /><category term="phptarsier" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/phptarsier/default.aspx" /><category term="ActiveRecordBase" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/ActiveRecordBase/default.aspx" /><category term="PHP 5 Framework" scheme="http://community.devpinoy.org/blogs/jbeduya/archive/tags/PHP+5+Framework/default.aspx" /></entry></feed>