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

SitePoint PHP Blog:
3 More Joins You Should Be Familiar With
Feb 08, 2016 @ 18:18:36

On the SitePoint PHP blog Zach Wallace shares more database wisdom with his readers introducing three more JOINs you should know in your development work.

There are many ways to JOIN data from two database tables and filter the information you require. Craig Buckler wrote a popular piece on understanding JOINs; namely INNER, LEFT, RIGHT, and FULL OUTER. This article is an extension of that one.

He starts with the data he'll be working with: customers and books, linked by a book_id column. He then quickly reviews some of the joins already discussed in the previous article (LEFT, RIGHT, OUTER, INNER) before getting into the newer, more powerful types:

  • LEFT JOIN with Exclusion
  • RIGHT JOIN with Exclusion
  • OUTER JOIN with Exclusions

He finishes the post with a few other thoughts about using WHERE clauses in JOINs, the CROSS JOIN and how the JOINs relate to each other in MySQL.

tagged: join database three list inner outer left exclusion advanced example tutorial

Link: http://www.sitepoint.com/3-more-joins-you-should-be-familiar-with/

Anna Filina:
Reduce number of queries
Oct 29, 2014 @ 15:53:10

In her most recent post Anna FIlina makes a recommendation to those looking to increase the performance of an application, especially one that's already in place: simply reduce the number of queries. It sounds simple enough, but can sometimes prove to be difficult depending on the application.

Customers often call me because their site is slow. One of the most common problems I found was a high number of queries that get executed for every single page hit. When I say a lot, I mean sometimes more than 1000 queries for a single page. This is often the case with a CMS which has been customized for the client’s specific needs.

In this article, aimed at beginner to intermediate developers, I will explain how to figure out whether the number of queries might be a problem, how to count them, how to find spots to optimize and how to eliminate most of these queries. I will focus specifically on number of queries, otherwise I could write a whole tome. I’ll provide code examples in PHP, but the advice applies to every language.

She suggests starting from "the top", looking at the browser's own information on which pieces of data are taking the longest to return back to the client (the latency). This gives a starting direction and tells you where to look for the worst offenders. She talks about a technique to locate and count the queries being made and some common issues found in multiple kinds of software (hint: loops). Then she gets down to the optimization - combining similar queries and better queries through joins.

tagged: query database performance join similar tips

Link: http://afilina.com/reduce-number-of-queries/

MaltBlue.com:
ZendDbSql - Creating Joins and Unions with Ease
Jul 01, 2013 @ 14:41:51

On the MaltBlue.com blog Matthew Setter has a new post about the ZendDbSql component of Zend Framework 2, specifically related to making easy joins and unions. This is the second part of his series on this component.

In the first part of this series on ZendDbSqlSelect, we jumped the gun a bit and went straight in to looking at building Where clauses. We looked at a number of the predicates that are available to us, such as In, Between and EqualTo and saw just how easy ZendDbSqlSelect makes both building and maintaining queries. In this, the second part, we’re backtracking a bit and looking at Joins and a slightly more esoteric feature of SQL – UNIONs. By the end of today’s tutorial, you’ll be building some pretty good queries that should satisfy most of your daily requirements.

He starts with a look at joins, showing in several code examples the various kinds - inner, outer, left and right (as well as self joins). He then moves on to unions, intersects and excerpts with examples of each.

tagged: zendframework2 tutorial sql db tutorial join union

Link: http://www.maltblue.com/tutorial/zend-db-sql-creating-joins-and-unions-with-ease

Rob Allen's Blog:
One-to-Many Joins with Zend_Db_Table_Select
Feb 08, 2012 @ 15:28:20

Rob Allen has a tip for the Zend Framework users out there using the Zend_Db module to connect to their database resources - how to do a one to many join with the help of Zend_Db_Table_Select (easier than it sounds).

Let's say that you want to set up a one-to-many relationship between two tables: Artists and Albums because you've refactored my ZF1 tutorial. [...] Assuming you're using Zend_Db_Table, the easiest way is to turn off the integrity check and do a join in a mapper or table method.

He includes a few lines of source to illustrate, calling the "setIntegrityCheck" value to "false" to tell ZF not to worry about the additional join value over to the artists table. The result is a new column value with the artist's name instead of just the ID.

tagged: onetomany database table join zendframework zenddb component

Link:

Anna Filina's Blog:
Doctrine Translation in leftJoin()
Apr 26, 2010 @ 16:39:33

In a recent post to his blog Anna Filina looks at internationalization in Doctrine and how Symfony auto-builds things to take care of it for you.

If you use Doctrine, then you probably know how lazy loading can hurt your performance. I carefully craft every query to everything that I need in one shot, but only what I need. One thing that evaded me at first was the i18n part. I am pleased with the way Doctrine + symfony magically creates all my models and database tables with i18n support.

She talks a bit about the internationalization (i18n) support is put into the schema.yml file and the bit of confusion she had over how to handle a left join using its structure. The key lies in the Translation relationships.

tagged: doctrine translation left join i18n internationalization

Link:

Keith Casey's Blog:
Joining a Startup
Dec 31, 2009 @ 17:19:54

Many software developers (the ones that haven't been in on a start-up usually) are tempted to make the jump into the seemingly glamorous start-up world to build that next killer web app. Keith Casey has posted a bit of a reality check for developers thinking of making the move.

In the last few weeks, I've talked with a number of friends about career changes. Some are feeling antsy and just want to move, others are starting their own consulting, and others are starting and joining startups. While I've done all the above - to varying levels of failure success - I thought I'd share the things I've learned along the way.

He gives six things to keep an eye out for when considering your entry into the startup world:

  • Everyone does everything
  • There's no career path
  • You never have enough money
  • v1.0 never looks like the original Vision
  • Every founder believes in him/herself
  • Most startups don't explode, they fizzle

He's not saying all of this to push you away from startups, though - more to help you go in "with eyes open" and ready to ask the harder questions before you get into a bad situation.

tagged: startup join advice opinion

Link:

Micheal Kimsal's Blog:
Symfony __toString() generation
Aug 20, 2008 @ 16:14:50

Michael Kimsal has pointed out a small irritation when using the Symfony framework and models - an issue when using models that have relationships.

If there are relations (an Author has a Book, for example). the generated forms will complain that the generated Models need a __toString() method to be used in the Form/View. In grails, this is the case, but every domain (corresponding to a Symfony 'model') has an implicit toString() method already generated, which return the string ":". For most production work, you’ll want to override it with whatever you need the string to read, but for prototyping, it's fine.

He went in and modified the Symfony core to add in a __toString call that would return the object correctly. Several of the commentors agree with his frustration and some of the Symfony developers even chime in with some of the reasoning behind why it's like that.

tagged: symfony tostring generation model issue join

Link:

Patrick Reilly's Blog:
Join the PHP Evangelism Team - Mailing List
Oct 17, 2007 @ 18:31:00

Patrick Reilly has posted about a new group that's being formed in the PHP world - a PHP Evangelism Team designed to help promote the language.

The goal of the PHP Evangelism Team is to bring together the right people, resources and experience from across the PHP Community to provide developers with the process guidance and best practices needed to create new opportunities for the web.

They're also looking to help support local user groups and aid in any PHP-related event they can. You can subscribe to their mailing list to get more information as the group develops. Check out the post for the address to join the list.

tagged: team evangelism join mailinglist usergroup support resources team evangelism join mailinglist usergroup support resources

Link:

Patrick Reilly's Blog:
Join the PHP Evangelism Team - Mailing List
Oct 17, 2007 @ 18:31:00

Patrick Reilly has posted about a new group that's being formed in the PHP world - a PHP Evangelism Team designed to help promote the language.

The goal of the PHP Evangelism Team is to bring together the right people, resources and experience from across the PHP Community to provide developers with the process guidance and best practices needed to create new opportunities for the web.

They're also looking to help support local user groups and aid in any PHP-related event they can. You can subscribe to their mailing list to get more information as the group develops. Check out the post for the address to join the list.

tagged: team evangelism join mailinglist usergroup support resources team evangelism join mailinglist usergroup support resources

Link:

IBM developerWorks:
Turn SQL into XML with PHP
Jul 25, 2007 @ 14:21:00

On the IBM developerWorks site today, there's a new tutorial by Vikram Vaswani walking through the use of the XML_Query2XML PEAR package to pull data from your SQL database and push it into an XML structure.

Ever wished for an easy way to transform SQL result sets into XML? It's a PEAR package named XML_Query2XML, and it provides a comprehensive framework to efficiently turn the results of a database query into a customizable XML document. This article introduces the package, and demonstrates useful real-world applications, including using it with XSL and XPath, combining it with data from external Web services, and creating database dump files.

They go through the installation and the steps to create the XML:

  • Convert SQL to XML
  • Transform XML output with XSL
  • Customize XML output
  • Work with SQL joins
  • Filter SQL records with XPath
  • Merge data from multiple sources
  • Create database backups

Check out the full tutorial for an excellent guide to using this powerful PEAR package.

tagged: pear xmlquery2xml xsl xpath join install backup pear xmlquery2xml xsl xpath join install backup

Link:


Trending Topics: