 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Gonzalo Ayuso: Multiple inheritance with PHP and Traits
by Chris Cornutt December 19, 2012 @ 13:17:48
Gonzalo Ayuso has a new post today showing how you can use traits in PHP to simulate a kind of multiple inheritance.
Multiple inheritance isn't allowed in PHP. [It's not] possible with PHP (in Java is not possible either), but today we can do something similar (is not the exactly the same) with Traits. Let me explain that: Instead of classes we can create Traits.
He includes a code example showing the creation of two traits, "Base1" and "Base2", that are implemented (via "use") and the calls to methods on each. He also points out the error condition and message that can come up when there's a conflict in the method names between two or more traits. This is relatively easy to solve with the mapping ability of the "use" statement (code example included for that too).
voice your opinion now!
multiple inheritance traits python example mapping use
DevShed: Building an ORM in PHP Domain Modeling
by Chris Cornutt November 22, 2011 @ 16:46:10
Continuing on from the first part of their series, DevShed has posted part two of their "Building an ORM in PHP" series. This latest tutorial focuses on domain modeling (and collection handling).
In that first part, I implemented the ORM's data access and mapping layers. And as you'll surely recall, the entire implementation process was pretty straightforward and easy to follow. Of course, in its current state the ORM is still far from a fully-functional structure. We need to add some additional components to it, such as a domain model and the classes responsible for handling collections of entities (remember that the ORM relies heavily on the data mapper pattern to do its business properly).
He stays with his "simple blog" example and shows domain models (based on an abstract entity) for Entries, Comments and Authors. His containers extend the Countable, IteratorAggregate and ArrayAccess interfaces to give them some extra abilities.
voice your opinion now!
tutorial domain model orm database mapping relational
DZone.com: The era of Object-Document Mapping
by Chris Cornutt July 08, 2011 @ 11:45:46
On the PHP on Windows section of DZone.com today Giorgio Sironi has posted about a different sort of object mapping than is usually thought of with databases - object-document mapping.
The Data Mapper pattern is a mechanism for persistence where the application model and the data source have no dependencies between each other. [...] But everytime we talk about the Data Mapper pattern, we assume there is a relational database on the other side of the persistence boundary. We always save objects; we always map them to MySQL or Postgres tables; but it's not mandatory.
He talks about two projects, MongoDb_ODM and CouchDb_ODM, that the Doctrine project is working on to help make working with document-driven databases as simple as the usual ORMs. He includes a brief code snippet showing how the feature will work (hint: a namespace of Document instead of Entity). He lists some of the features - including the usual ORM capabilities, support for collections, cascade of persistence - and where you can get the latest code for it (from github and PEAR
voice your opinion now!
object document mapping doctrine mongodb couchdb
Derick Rethans' Blog: PHP and Ordnance Survey Mapping
by Chris Cornutt April 28, 2010 @ 10:55:14
Derick Rethans, indulging his "map geek" side, has written up a new post showing how he took the data from Ordnance Survey and mapped some information in the UK - postcode density for the whole area.
I decided to map all the postcodes onto the UK map where more postcodes for a specific place would create a "lighter" colour. Each postcode has on average about 15 addresses, so in more densely populated areas you have more "postcodes-per-area". Doing this wasn't very difficult and it resulted in the following map.
He walks through the entire process including how, in working with the data, he noticed alignment issues caused by the differing projections the map information service uses (Mercator) versus just mapping to a flat image. Some calculations were made to convert the latitude/longitude to the correct locations and the resulting points were plotted on a cut-out image of the UK.
After I figured out all the maths for this, the only problem that remains that implementing those algorithms in PHP is show-calculating all the positions from the 1.6 million postcode locations takes up to 10 minutes. This is why I am not presenting any code yet. I am planning to implement all the necessary calculations in a PHP extension to speed up the calculations.
voice your opinion now!
ordnance survey mapping uk postcode
DevShed: Using Code Igniter to Build an IP-to-Country Mapping Application
by Chris Cornutt February 25, 2009 @ 07:57:11
DevShed finished off their tutorial series looking at mapping IPs to countries in a CodeIgniter application with this new article completing the application to provide a correct products list based on their location.
In this final chapter of the series, I'll be discussing how to build multi-lingual web pages by combining the functionality brought by the "iptocountry" MySQL table that you learned in previous tutorials and the power of the Code Igniter PHP framework.
Their database tables sort the prodcuts out with the three character country code they're associated with. The IP-to-country tables then help with the translation between the visitor's IP address and which products should be shown.
voice your opinion now!
country ip mapping products codeigniter framework
DevShed: Generating Web Pages in Multiple Languages with a PHP IP-to-Country Mapping Application
by Chris Cornutt February 19, 2009 @ 12:03:18
DevShed has the next in their "IP to country" series posted today, this new tutorial showing how to create a more customized site (a simple page or two) with the IP detection and a front controller.
Welcome to the third part of a series on developing an IP-to-country mapping application with PHP. Made up of four approachable tutorials, this series teaches you how to create a program like this by using a single MySQL lookup table, and shows you how to use this program to enrich your own web sites with geo-location capabilities.
They use the mapping data you pulled from the Webnet77 ip-to-country database (and dropped into the MySQL database) to evaluate where the user is coming from and display product information based on the two letter country code it returns. They throw in a bit about a front controller too, a simpler way to ensure that the user's location code is set for every request.
voice your opinion now!
mapping application front controller mysql database tutorial
DevShed: Building Sample Programs for an IP-to-country Mapping Application
by Chris Cornutt February 11, 2009 @ 08:44:29
DevShed has posted the second part of their series looking at an IP-to-Country mapping application, this time with a focus on building some simple applications to use the data inside.
Building a web site that will be seated on a multi-lingual platform often requires developing an IP-to-country application that permits you to map users' IP addresses to their corresponding countries. [...] This database contains over 82,0000 records and allows you to map more than 3,200,000 IP addresses to their respective countries. This can be really handy for developing different IP-to-country applications with minor efforts.
The review the previous article on making the database and move ahead to create a script that selects - based off the IP range - the country that address could be from.
voice your opinion now!
ip translate country mapping application program tutorial
DevShed: Building an IP-to-Country Mapping Application with PHP
by Chris Cornutt February 04, 2009 @ 08:47:30
DevShed has launched a new four-article series today looking at resolving a user's IP to their country via the database provided here.
If you have content in several different languages, your visitors probably speak several different languages as well. Wouldn't it be nice to serve them content from your site in their native language, based on the country from which they hail? You can, even if you're a small company, with an application that tells you a visitor's country based on their IP address. This four-part article series will show you how to build the application and incorporate it into your web site.
They just get things set up in this first part of the series - grabbing the CSV file from the site, creating the MySQL table to import it into and running a script to parse the CSV and push its data into the table.
voice your opinion now!
tutorial ip country mapping csv database mysql
|
Community Events
Don't see your event here? Let us know!
|