<?xml version="1.0" encoding="iso-8859-1"?>

<rdf:RDF 
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns="http://purl.org/rss/1.0/"
>
		
		
		
	<channel rdf:about="http://www.justicesolutionsllc.com/blogcfm">
	<title>Justice Solutions LLC Blog</title>
	<description>Powered by BlogCFM</description>
	<link>http://www.justicesolutionsllc.com/blogcfm</link>
	
	<items>
		<rdf:Seq>
			
			
			
				
			<rdf:li rdf:resource="http://www.justicesolutionsllc.com/blogcfm/1/2008/02/57.Getting-the-CRUD-out-in-your-code.cfm" />
			
			
		</rdf:Seq>
	</items>
	
	</channel>
		
		
		
		
		
		
		
		
		
  	<item rdf:about="http://www.justicesolutionsllc.com/blogcfm/1/2008/02/57.Getting-the-CRUD-out-in-your-code.cfm">
	<title>Getting the CRUD out in your code</title>
	<description>Ok, it&apos;s Thursday Tips Day, and I wanted to show you a very handy tool you can be using to speed along your development time, or help your web department speed their development time along at your own company.&lt;br /&gt;
&lt;br /&gt;
The tool is called an Object Generator or an O/R Mapper.&amp;nbsp; Some also like to call them &amp;quot;CRUD&amp;quot; Tools.&amp;nbsp; CRUD is an acronym we geeky coders like to use that stands for:&amp;nbsp; Create, Read, Update, Delete.&amp;nbsp; In almost every basic web application out there today, we are asked to interface with some type of database or datasource.&amp;nbsp; And in almost every instance of that interfacing we (the coders) are doing some type of call to the database.&amp;nbsp; It could be reading one record, getting several records, updating a record, or even deleting one.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Writing these calls can be very mundane.&amp;nbsp; Ones I usually save for my new coders to do &lt;em&gt;&lt;strong&gt;&amp;lt;insert evil laugh here&amp;gt;&lt;/strong&gt;&lt;/em&gt;.&amp;nbsp; However, these CRUD or Object Generator tools can help things along tremendously in development time, which then allows us or your web developers, time to focus on things that are usually overlooked or zipped through at the end of a project such as field validation, styles, SEO, etc.&lt;br /&gt;
&lt;br /&gt;
For ASP.net we personally like to use O/R Mapper (&lt;a target=&quot;_blank&quot; href=&quot;http://www.ornetmapper.com&quot;&gt;www.ornetmapper.com&lt;/a&gt;).&amp;nbsp; The thing I personally like about this open source tool is the simple fact that the developer continues to really improve this tool with newer and more awesome releases than its prior.&amp;nbsp; As of this updated blog, the latest version is version 6, and it&apos;s come a long way and really could be the easiest most comprehensive way to develop the business logic for your next .NET project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;A Screen Shot of O/R Mapper (the ASP.NET Object Mapper Tool)&lt;br /&gt;
&lt;/strong&gt;&lt;img vspace=&quot;10&quot; hspace=&quot;5&quot; border=&quot;1&quot; src=&quot;http://www.justicesolutionsllc.com/images/ss_ormapper_1.jpg&quot; alt=&quot;O/R Mapper Screen Shot&quot; /&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;
&lt;div align=&quot;left&quot;&gt;And using the code is even easier than using the tool itself in .NET.&amp;nbsp; So here&apos;s a quick example.&amp;nbsp; Let&apos;s say you have a table called Users and in your datagrid you have your typical select button which triggers your onSelect event in your code behind.&amp;nbsp; So now you want to populate a few text boxes in your form for editing.&amp;nbsp; Here it goes....in C#.net&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  Users u = new Users();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  UsersAssembler a = new UsersAssembler();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp; UsersCriteria c = new UsersCriteria();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  c.Set_Username(CriteriaBase.AVAILABLE_STRING_OPERATORS.EQUALS, &amp;quot;doug&amp;quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  u.ReadSingle(c);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &lt;br /&gt;
Now that you have the information loaded into the &amp;quot;u&amp;quot; object...you just assign your textboxes accordingly....&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  tbUsername.Text = u.Username;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  tbPassword.Text = u.Password;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  tbFirst.Text = u.FirstName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp; tbLast.Text = u.LastName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  etc.&lt;br /&gt;
&lt;br /&gt;
Did you blink and missed it?&amp;nbsp; Yes it&apos;s that quick.&amp;nbsp; You can also retrieve lists of results and do things like auto-bind it to your gridview, etc.&amp;nbsp; Really really cool.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For PHP, we personally like to use POG.&amp;nbsp; (&lt;a target=&quot;_blank&quot; href=&quot;http://www.phpobjectgenerator.com&quot;&gt;www.phpobjectgenerator.com&lt;/a&gt;) This nifty little online tool will allow you to not only create the code classes you&apos;ll need to interface easily with your web application, but also build your tables for you.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &lt;br /&gt;
&lt;/div&gt;
&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt;A Screen Shot of POG (the PHP Object Generator Tool)&lt;/strong&gt;&lt;/div&gt;
&lt;img vspace=&quot;10&quot; hspace=&quot;5&quot; border=&quot;1&quot; src=&quot;http://www.justicesolutionsllc.com/images/ss_pog_1.jpg&quot; alt=&quot;POG Screen Shot&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Once all of your code and tables are built, its a snap to interface with them.&amp;nbsp; Let&apos;s say you have a table which has your user&apos;s vital information in it and you want to retrieve a list of users that have signed up in the past week.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;lt;?PHP&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Create a new instance of our POG class for Users&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; $u = new users();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp; // Call the GetList Function to bring us back a list of users meeting our criteria&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  $userList = $u-&amp;gt;GetList(array(array(&amp;quot;signupdate&amp;quot;,&amp;quot;&amp;gt;=&amp;quot;,&amp;quot;2008-02-16 00:00:00&amp;quot;)));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  // Now loop through the results and display them for the end user to view&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  foreach($userList as $user)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  echo &apos;&amp;lt;p&amp;gt;User Name: &apos; . $user-&amp;gt;username . &apos; &amp;lt;br /&amp;gt;Name: &apos; . $user-&amp;gt;first . &apos; &apos; . $user-&amp;gt;last . &apos;&amp;lt;br /&amp;gt;Signup: &apos; . $user-&amp;gt;signupdate . &apos;&amp;lt;/p&amp;gt;&apos;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pretty simple huh?&amp;nbsp; And you can send as many criteria you want in additional arrays all in that same GetList() function.&amp;nbsp; So the speed at which you get results and have the ability to update them are fast and easy.&lt;br /&gt;
&lt;br /&gt;
So take some time to check out POG or send this blog link to your favorite PHP coder.&amp;nbsp; They very well may thank you for it, however knowing most coders they&apos;ll probably say they already knew about it, thanks for the link, and then when people aren&apos;t looking will start to use it all the time.&amp;nbsp; Ha!!&amp;nbsp; Happy coding!&lt;br /&gt;
&lt;br /&gt;
Doug.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;</description>
	<link>http://www.justicesolutionsllc.com/blogcfm/1/2008/02/57.Getting-the-CRUD-out-in-your-code.cfm</link>
	<dc:date>2008-02-21T08:44:00-07:00</dc:date>
	
	<dc:subject>ASP.NET,Web Development, Web Consulting, Web Applications,PHP, Code Help</dc:subject>
	</item>
	
	
 	
	</rdf:RDF>
	

