 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPClasses.org: PHP Object-Relational Mapping ORM or ROM?
by Chris Cornutt October 10, 2008 @ 12:09:37
On the PHPClasses.org blog today Manuel Lemos has posted a look at ORM - what it is and how you can use it to improve your applications.
Object-Relational Mapping, usually referred as ORM, is a software development approach to treat data stored in relational (SQL) database table records as if they were objects. Basically we can create classes with variables that represent fields of a database table. To insert a table record you need to create an object of the class, assign the variable values, and call a function of the class that takes care of inserting the table record
He illustrates what it is (brief code samples) and some of the approaches that developers have taken to implementing it. He suggests, however, that they should truely be called ROM (Relational Object Mapping) libraries rather than ORM due to the fact that they map an object (the database tables) back in to PHP objects. He finishes with a list of a few ORM resources and libraries including the one that helps power the PHPClasses website, Metastorage.
voice your opinion now!
phpclasses orm object relational mapping database layer
ParticleTree.com: Object Oriented Memory Concerns
by Chris Cornutt September 18, 2008 @ 11:17:00
In a new article to his blog, Ryan Campbell has expressed some concerns in the amounts of memory that some of the object oriented practices in PHP are using these days.
It's hard to imagine pushing the limits of object oriented PHP so far that your web servers choke, but the truth is those limits are reached faster than you think. [...] While replacing objects with arrays when possible makes things a little better, the most performance friendly approach involves appending strings. For your convenience, we've run some tests that measure page execution times and memory usage to create the following guideline to help you plan out what areas of your code may have to break away from an object oriented nature.
He shares some benchmarks of the memory use for different variable types - strings, arrays and objects - giving load times and the amounts of memory used. He mentions three workarounds that could help (unset, static methods and paging) reduce the memory consumption of your script.
voice your opinion now!
oop object oriented memory concern unset static benchmark
PHP in Action: Type hints are more useful for scalars than objects
by Chris Cornutt September 11, 2008 @ 10:08:33
On the PHP in Action blog, there's a new post looking at a recent library that was posted to support type hinting on scalars. They agree with his choice of subjects, noting that they see type hinting as much more useful on scalars than on objects.
I admit that these judgments are hard to make. I could be wrong, more or less. Type hints are probably useful when code becomes stable enough and at the boundaries between modules. But I still tend to avoid using them until I get an actual bug that might have been prevented by a type hint. Their usefulness is and has to be an empirical question. The purpose of using them has to be catching errors earlier, so if they don't have that effect, there's no point.
He lists three reasons why he had given up on type hinting before, one being the limited usefulness when it came to objects. Applying it to scalars is a different matter, though, and can prevent improper passing of array/scalars when the other is needed.
voice your opinion now!
type hinting scalar object array string class library
Lorna Mitchell's Blog: PHP REST Server (Part 3 of 3)
by Chris Cornutt September 05, 2008 @ 12:55:48
Lorna Mitchell has posted the last part of her development process towards creating a sample REST server in PHP:
This is part 3 of my article about writing a restful service server. If you haven't already, you might like to read part 1 (covering the core library and grabbing the information we need from the incoming request) and part 2 (covering the service handler itself) before reading this section. This part covers the Response object that I used to return the data to the user in the correct format.
She show how she created the object to push the response back out to the client with an output() method that displays the XML response in a manually generated format.
voice your opinion now!
rest server tutorial response xml object
David Otton's Blog: Neat PHP tricks Casting Arrays to Objects
by Chris Cornutt August 14, 2008 @ 13:38:10
David Otton has a handy little tip if you're looking for a cleaner way to deal with array data - casting it to an object.
Array notation is fine, but it can look a bit clunky when you're working with complex structures. [...] Casting the array to an object allows us to use object notation (->) and makes the code more readable.
He includes examples of the casting, showing the difference between the array and object notations including a method for creating an object based on a simple array that has basic properties built in. This sort of transformation can be useful if you want consistency through out the application - just passing objects with their properties rather than arrays.
voice your opinion now!
array object casting trick notation readable
Havard Eide's Blog: SplObjectStorage
by Chris Cornutt July 23, 2008 @ 08:47:44
Havard Eide has a recent post to his blog that looks at a part of the Standard PHP Library (SPL) that can be used with objects to store them for later use - SplObjectStorage.
In this post I will look at SplObjectStorage: a container that allows to store objects uniquely without the need to compare them one by one.
He lets the code to most of the talking, showing how to do the standard operations for a data store - adding objects (both unique and the same), updating objects in the store, checking to see if an object is already added and removing an object from storage.
voice your opinion now!
splobjectstorage add unique update check data storage object remove
PHPImpact Blog: Static Factories vs Public Constructors
by Chris Cornutt July 18, 2008 @ 12:58:31
On the PHP::Impact blog Federico Cargnelutti has posted a comparison of using static factory methods to create an instance of a class versus making an object, calling the constructor.
Normally, creating an instance of a class is done by calling new, which calls the constructor. Static factory provides a static method that returns an instance of the class. So, you are using static factory instead of the constructor. Providing a static factory method instead of a public constructor has both advantages and disadvantages.
He includes some of the advantages of the factory method and others for the normal call to create an object. He also mentions some comments made by Dagfinn Reiersol in a blog post about public constructors.
voice your opinion now!
static factory designpattern constructor object instance
Developer Tutorials Blog: Getting Started with ORM in PHP
by Chris Cornutt July 16, 2008 @ 09:35:27
A recent post on the Developer Tutorials blog takes a look at a fundamental part of several of the PHP (and other language) frameworks out there - the Object Relational Mapping (ORM) layer for database access.
Instead of direct database access, an ORM layer in a PHP framework can make "objects" stored in a database behave like actual objects from a programming perspective - for example, creating a new "car" stored in the database could involve a call to $car->new(). By abstracting actual database access, web development can be more productive and result in more reliable applications. Here's a quick intro to ORM in PHP.
They talk about ORM's role in how applications interface with data (abstracted out to objects) and some examples of it in current frameworks - CakePHP and Symfony.
voice your opinion now!
orm object relational mapping cakephp framework symfony
|
Community Events
Don't see your event here? Let us know!
|