Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lorna Mitchell's Blog:
Retrieving Product Attributes from Magento's V2 API
Jul 12, 2010 @ 13:28:14

Lorna Mitchell has posted a sort of follow-up to her previous post about accessing the Magento A{I to pull information about products from the application. In this new post she takes it a step further and shows how to get attributes from those products.

I've been working with the API for Magento in recent weeks and I had a bit of a struggle explaining to the V2 API which attributes of a product I wanted to retrieve. Actually I had issues talking to the V2 API at all, but that's a different post so I'll skate over those for now. Instead I thought I'd share (or rather, record for the next time I have the same problem!) how to specify which attributes about a product to retrieve.

She figured out that you could use the info method for the product_catalog call and specify the attributes you want. Her code example shows how to fetch the title, description, a shorter description and the price of an item.

tagged: magento product attribute tutorial api

Link:

Sebastian Bergmann's Blog:
The Cost of Test Isolation - Follow-Up
Jan 20, 2009 @ 17:11:44

Adding on a bit more to a previous post of his look at test isolation (ex. global variables from one test do not effect any others') with an update he's made to the PHPUnit code concerning the isolation.

Since the previous posting, I have added a backup/restore mechanism for static attributes of classes to PHPUnit. This is yet another feature of PHPUnit that makes the testing of code that uses global state (which includes, but is not limited to, global and superglobal variables as well as static attributes of classes) easier.

Two graphs illustrate the difference - one showing a normal run and another with this new feature in use and showing off the performance increase it can give.

tagged: test isolation phpunit xdebug backup restore static attribute

Link:

Jani Hartikainen's Blog:
What would make template engines actually useful?
Jan 19, 2009 @ 14:44:10

In a recent blog post, Jani Hartikainen looks at a two things that might make templating tools a bit more useful - better than just dropping data into a template.

Most template engines simply wrap PHP (or some other languageā€™s) syntax into their own syntax, and maybe they look a little bit cleaner when mixed with HTML. Some may even provide useful features like automatic variable escaping to prevent XSS vulnerabilities. But does this actually significantly reduce the amount of code needed to write some common scenarios, or make it easier to read/manage the code?

His two things revolve some bits of more advanced functionality - automatic table display (given whatever data) and automatic filtering of the data to make of less hassle on the developer/template designer. He even mentions an interesting idea of putting callbacks or validation checks into the actual XML definition tags for forms.

tagged: template engine useful filter table generte attribute callback

Link:

PHP in Action:
Get links with XPath
Oct 07, 2008 @ 13:43:33

In response to this tutorial over on the PHPro.org website a new post has been made to the PHP in Action blog with an "even cooler" way to do the same sort of DOM fetching - XPath.

I'm a little bit surprised at the claim [the tutorial makes] that it's the "correct" (only) way, since there's at least one more that I find even cooler: XPath. Admittedly, it's slower, yet it's a more powerful language.

A quick example is included, building up from a simple search for anchor tags up to a custom query looking for just the anchor tags with a class of "bookmark".

tagged: xpath tutorial dom link find search anchor attribute

Link:

Arnold Daniels' Blog:
An alternative way of EAV modeling
Jul 31, 2008 @ 17:54:23

Arnold Daniels has posted some thoughts on a topics recently featured in a cover story by php|architect - EAV modeling.

I had seen this db structure in other project, but didn't know that it was called EAV. For those who don't read php|architect, EAV describes a method of saving a large set of attributes, only some of which apply to an individual entity. Normally you would create a table, with a row for each entity and save each attribute in a column. With EAV you save each attribute as a row.

He suggests two ways to do the modeling - the more "common" way and an alternative way that splits up the data types to make querying simpler (into scalars and arrays). A sample database structure and example query for it are included.

tagged: eav modeling database attribute query common alternative method

Link:

DevShed:
Accessing Attributes and Cloning Nodes with the DOM XML Extension in PHP 5
Apr 01, 2008 @ 20:11:43

DevShed continues their series about working with XML in PHP's DOM extension with this new tutorial posted today showing how to get at attributes for tags and cloning nodes from others.

You've probably realized that the DOM XML library can be pretty useful when working with web documents. However, this extension includes some other methods, which can be utilized to parse attributes of a given XML string, as well as to clone nodes.

They show how to use the getAttributes method, hasAttribue method and cloneNode method to work with their XML examples.

tagged: php5 clone node xml tutorial attribute node dom

Link:

DevShed:
Inserting Comments and Accessing Nodes with the DOM XML Extension in PHP 5
Mar 11, 2008 @ 20:40:21

DevShed continues their series looking at using the DOM extension in PHP5 to work with XML in your application. They've already looked at adding attributes and creating CDATA information in a new DOM document. This time they build on that and also include new methods - appending comment nodes and getting at XML nodes by their IDs.

I'm talking about the DOM XML extension, which allows you to handle XML documents by using the DOM API. Thus, if you're interested in learning how to put this extension to work for you quickly, look no further, because you've come to the right place. [...] In this third installment of the series, I'll be teaching you specifically how to append comment nodes to a given XML string and how to extract certain elements via their IDs.

They review the method to add attributes and CDATA to an XML document first. Then they cover the other two new topics - appending comment nodes and grabbing nodes by their ID attribute.

tagged: dom extension php5 node cdata attribute id fetch tutorial

Link:

Derick Rethans's Blog:
HTML name attribute deprecated
Oct 23, 2007 @ 17:52:00

Derick Rethans has pointed out a "gotcha" that was passed along to him (somewhat incorrectly) about the "name" attribute being deprecated in XHTML 1.0.

Just now somebody on IRC was claiming that the "name" attribute in HTML - the one that is used to give form input fields a name to be used in $_GET and _$POST in PHP is in fact deprecated. [...] But if you read correctly, it's only for the elements: a, applet, form, frame, iframe, img, and map.

For the official information, check out the section of the new spec dealing with this transition.

tagged: name attribute xhtml deprecated element name attribute xhtml deprecated element

Link:

Derick Rethans's Blog:
HTML name attribute deprecated
Oct 23, 2007 @ 17:52:00

Derick Rethans has pointed out a "gotcha" that was passed along to him (somewhat incorrectly) about the "name" attribute being deprecated in XHTML 1.0.

Just now somebody on IRC was claiming that the "name" attribute in HTML - the one that is used to give form input fields a name to be used in $_GET and _$POST in PHP is in fact deprecated. [...] But if you read correctly, it's only for the elements: a, applet, form, frame, iframe, img, and map.

For the official information, check out the section of the new spec dealing with this transition.

tagged: name attribute xhtml deprecated element name attribute xhtml deprecated element

Link:

Christopher Jones' Blog:
New PDO_OCI Attributes
Sep 19, 2007 @ 14:37:00

Christopher Jones talkes about some updates that he's made to the default PDO functionality of PHP, adding in a few things like pre-fetching and methods to get the details of the database server you're using.

After PHP 5.2.4 shipped and a new release cycle began, I merged a couple of enhancements to PDO_OCI attribute handling. Specifically I added $dbh->getAttribute() support for ATTR_SERVER_VERSION, ATTR_SERVER_INFO, ATTR_CLIENT_VERSION and. ATTR_AUTOCOMMIT. At the moment these are only available in the PHP snapshots on http://snaps.php.net/. Let me know if there are any issues so they can be resolved before the next PHP release.

He gives examples of two things - the pre-fetching functionality, allowing for better optimization for a query, and the transaction management features, making it as simple as a try{} block to test the commit and rollback if needed.

He also mentions other properties/attributes included in the new release - ATTR_PERSISTENT, ATTR_TIMEOUT, ATTR_ORACLE_NULLS, ATTR_CASE and ATTR_ERRMODE, ATTR_SERVER_VERSION and ATTR_CLIENT_VERSION (the last two have examples).

tagged: pdo oci oracle attribute prefetching transaction namagement pdo oci oracle attribute prefetching transaction namagement

Link:


Trending Topics: