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

MaltBlue.com:
ZendDbSqlSelect - The Basics (Columns, Limit & Order)
Jul 02, 2013 @ 09:53:32

Matthew Setter has posted the third part of his series looking at the Zend Framework 2's DbSqlSelect component and its use. In this latest (and last) tutorial, he talks more specifically about columns, limiting and ordering.

Welcome to the third and last part in this series, introducing you to working with the ZendDbSqlSelect classes in Zend Framework 2. In part one we looked at building SQL Where clauses using the where related functions, predicates and closures, as well as compound queries. In part 2, we looked at all forms of SQL joins as well as a slightly more esoteric feature of SQL – UNIONS. Here, in part 3, in the words of Coldplay, we’re going back to the start, and looking at the fundamentals.

He looks at three specific elements - the class constructor, the "limit" and "order" functions and the "Expression" class. He includes sample code showing how to create the class - one normally and one bound to a specific table. The next example shows how to define the columns to be selected using the "select" method. Finally, he shows the use of the "Expression" objects to perform SQL operations in the query (like "COUNT").

tagged: zendframework2 db sql select series part3 column limit order

Link: http://www.maltblue.com/tutorial/zend-db-sql-the-basics

SitePoint PHP Blog:
How to Split WordPress Content Into Two or More Columns
Feb 05, 2010 @ 12:58:00

On the SitePoint PHP blog there's a recent post from Craig Buckler showing how to split up your WordPress content into two or more columns quickly and easily.

WordPress is a great CMS, but implementing some features within your theme can require a little lateral thinking. The content for your page or post is usually output by the theme code using a single function call. But what if you need to split the content into two or more blocks? That might be necessary if your theme requires multiple columns or sections on the page.

There's a built in call WordPress includes, "get_the_content", that returns the content rather than just echoing it out. With this handy function giving you just the content, you're free to split up the content however you want - on certain tags or as they suggest, using the "more..." tag and a few modifications to a few other scripts to split it out into DIV blocks.

tagged: wordpress content tutorial split column

Link:

Chris Jones' Blog:
Inserting and Updating Oracle XMLType columns in PHP
Jul 13, 2009 @ 08:14:21

All of you Oracle users out there might want to check out this recent post from Chris Jones, especially if you've been using the XMLType columns in your tables.

Today a reader mailed me about manipulating XMLType columns when the data is longer than the 4K limit that character-type handling imposes. My free book (see sidebar) has examples of how to do this using CLOB handling in PHP. I noticed that my xmlinsert.php example in the book does a SELECT and UPDATE, but never actually does an INSERT.

To correct the problem of the missing example he includes example code to connect to the database, push the XML into a bind variable and select the row back out to ensure everything's still structured correctly. You need to set up a new descriptor for the insert to work (CLOB).

tagged: clob column xmltype xml oracle insert

Link:

Sameer Borate's Blog:
Selecting all except some columns in MySQL
Mar 02, 2009 @ 11:13:08

Sameer Borate shows how to turn things around in your application's SQL statement and, instead of selecting the columns you need, showing how to remove the columns you don't need dynamically.

The MySQL SELECT is a ubiquitous statement. You can select rows using the ‘*’ operator or by listing the individual column names. But many times you may require using all the columns from a table except a couple of them. For example you may have a table containing twelve columns from which you require only eleven columns.

Sometimes that extra column can contain larger content you might not need or want. He creates a get_column_names and create_statement functions that grab the column names and, based on an "exclude" array, takes out the unwanted records. The array is then looped through and appended back together as the new column list for the select.

tagged: select exception mysql column array remove

Link:

PHP Women:
PHPWomen in php|architect
Dec 30, 2008 @ 09:38:02

According to this quick note on the PHP Women site, the group has been featured in the latest issue (Dec 2008) of php|architect magazine.

PHPWomen are featured in the December issue of the php|architect magazine, we're the subject of this month's /etc column! If you aren't already a subscriber - then go and check out the options, they even have a free issue offer so there are no excuses.

The column, written by PHP Women's own Lorna Mitchell, looks at some of the goals of the group, the work they do sponsoring female developers where they can, their mentoring programs and the communication methods - IRC and forums - that are open to all, not just female developers.

You can check out the issue here (and order a copy too!)

tagged: phpwomen article column etc phparchitect magazine lornamitchell

Link:

Lee Blue's Blog:
How To Sort A Zend_Db_Table_Rowset
Feb 14, 2008 @ 17:11:00

Lee Blue has posted a handy tip for users of the Zend Framework, specifically when sorting the results from a query to tables linked in a Zend_Db_Table setup.

So you figured out how to define the relationships between your Zend_Db_Tables and you have issued a call to findDependentRowset(). You get your Rowset back but you need to sort the results by one of the columns in the dependent table. How do you do that?

Unfortunately, he's found out that you just simply can't - well, not without a custom function (until the 1.5 release of the framework rolls around). He shows his table set up and some sample database classes to relate to the tables (and link between them). The magic comes in with his DU_Utils class that takes in the data and sorts it based on the given column name in the given direction.

tagged: zendframework zenddb table relationship sort order column

Link:

php|architect:
January 2008 Issue Released
Jan 23, 2008 @ 16:34:00

This month's edition of php|architect magazine has been released - the January 2008 edition. Articles included in this month's issue include:

  • PHAR: PHP Archive Files from Gregory Beaver
  • Webmail 2.0: Introducing RoundCube by Tim Klampackel
  • Killing the For Loop from Paul Chandler
  • The Doctrine Framework by Nicolas Berard-Nault
  • and the usual columns - /Etc and Test Pattern

If you're already subscribed, you should be getting your issue any time now but, if you're not, there's two ways you can get your hands on a copy - either "quick buy" it from the php|architect website or subscribe and get this and other great future issues jam packed full of great PHP content.

tagged: phparchitect magazine issue january release article column

Link:

php|architect:
December 2007 Issue Released
Dec 18, 2007 @ 14:33:00

The php|architect group has released their December 2007 issue today. Articles featured in this issue include:

  • Going Native With mysqlnd by Andrey Hristov and Ulf Wendel
  • Understanding CLI by Dirk Merkel
  • Web Scraping by Matthew Turland
  • Product review: SQLyog MySQL GUI—Enterprise Edition by Eddie Peloke

...and the three usual columns - /etc, Security Corner and exit(0) from Marco Tabini.

You can get more information about this issue and on ordering it (or a year's subscription) from this page on the php|architect website.

tagged: phparchitect december issue release article column phparchitect december issue release article column

Link:

php|architect:
December 2007 Issue Released
Dec 18, 2007 @ 14:33:00

The php|architect group has released their December 2007 issue today. Articles featured in this issue include:

  • Going Native With mysqlnd by Andrey Hristov and Ulf Wendel
  • Understanding CLI by Dirk Merkel
  • Web Scraping by Matthew Turland
  • Product review: SQLyog MySQL GUI—Enterprise Edition by Eddie Peloke

...and the three usual columns - /etc, Security Corner and exit(0) from Marco Tabini.

You can get more information about this issue and on ordering it (or a year's subscription) from this page on the php|architect website.

tagged: phparchitect december issue release article column phparchitect december issue release article column

Link:

Jeff Moore's Blog:
Dependency Injection in PHP
Jun 27, 2006 @ 06:00:15

In his latest blog post, Jeff Moore adds a bit more background to his column in the newest issue of php|architect covering "dependency injection".

The June issue of PHP Architect is out. My column this month is on dependency injection, a topic which I've been warming up to lately.

First there was CORBA. Then insane complexity of CORBA was supplanted by the intolerable complexity of EJB. Influenced by an agile mindset and the power of Unit testing, a group of java programmers began to construct simpler alternatives to EJB. Thus, the inversion of control frameworks were born. Martin Fowler came along, clarified and renamed the pattern dependency injection. This activity has originated in the Java world, but the pattern applies in PHP as well.

It is heartening to see an industry solve a problem over the course of a decade, moving from complex vendor driven middle-ware to simple patterns. The thing I like most about DI is how dead simple it really is.

He goes on to say that Fowler's article on the topic is a "must read" for anyone who will even be looking into dependency injection. He also mentions two issues he has with most of the other introductions - the examples they use and the "over-emphasis on the container".

His goal in writing this month's column was to help to avoid some of those problems while still keeping it relevant and easy to understand.

tagged: dependency injection article column php|architect tutorial dependency injection article column php|architect tutorial

Link: