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

php[architect]:
The Dev Lead Trenches: Burning Out
Nov 05, 2018 @ 18:30:46

On the php[architect] site they've shared the contents of one of their regularly published columns - "The Dev Lead Trenches", written by Chris Tankersley - covering burnout of developers from their day-in and day-out work.

The tech industry is a double-edged sword. On the one side, we (generally) have well-paying jobs with nice perks, but on the other, we can easily slip into not only boring, repetitive work but figurative death marches. The former is used by most companies as an offset to the latter, but that rarely works out well. This leads many developers to come face-to-face with burnout.

He starts with some suggestions of ways to detect burnout in your own life including lack of motivation, sleep, and other emotional types of signs. He then makes a list of suggestions of how you can avoid burnout in your own work:

  • set working hours
  • use vacation time
  • take 15 minute breaks
  • take up hobbies outside of development

There's several others in the list too, so I'd recommend checking out the full article for more information about each.

tagged: devleadtrenches phparchitect column burnout detection avoid

Link: https://www.phparch.com/2018/10/the-dev-lead-trenches-burning-out/

Mohamed Said:
Laravel/MySQL JSON documents faster lookup using generated columns
Aug 22, 2017 @ 15:55:05

Mohamed Said has an interesting post to his site showing how to use computed columns for faster lookups in a MySQL database containing JSON documents.

Laravel 5.3 is shipped with built-in support for updating and querying JSON type database fields, the support currently fully covers MySQL 5.7 JSON type fields updates and lookups.

He includes an example of using the Eloquent DB handling to search for the data in the JSON and the results. He links to more information about the feature, following it up with an example of the main topic: computed columns. In it he shows how to create (on the SQL side) a generated/computed column that allows for easier extraction of the data directly from the JSON. This makes it even simpler to get the data just as you would in a normal select. He also includes an example of creating it via the Schema functionality in the database migrations.

tagged: mysql json column lookup computed generated sql data laravel tutorial

Link: https://themsaid.com/laravel-mysql-json-colum-fast-lookup-20160709

php[architect]:
Education Station: Simple, Compact Time Range Creation with Period
Jul 18, 2017 @ 15:08:48

php[architect] magazine has shared a column from their July 2017 issue, "Education Station" by Matthew Setter, looking at the use of Period for date and time handling.

For the longest time, I’ve enjoyed using PHP’s DateTime library. I’ve always found it to be relatively straightforward in creating DateTime objects for use with various applications I’ve written.

However, one thing that isn’t very simple, nor intuitive, is the ability to create time ranges—especially ones requiring some degree of sophistication, such as fiscal quarters, for financial reporting requirements. [...] It’s for [code reuse] reasons that I’m going to spend the [end] of the column introducing Period, a Time range API for PHP, maintained by The League of Extraordinary Packages.

He starts off by showing how to do things "the hard way" with the built-in PHP DateTime handling and how difficult it can be to work with ranges. In his example he tries to get the dates for a "quarter", a portion of a year usually used for business reporting purposes. He works through some of the issues he faced during the date calculations and things lie leap years and odd date ranges. He then introduces Period as a way to help solve some of these problems. He lists out the main goals of the project, installing the package and using it to get the same "quarter" dates as his attempt before.

tagged: educationstation column matthewsetter phparchitect july2017 issue period datetime

Link: https://www.phparch.com/2017/07/education-station-simple-compact-time-ranges/

Matt Stauffer:
New JSON-column where() and update() syntax in Laravel 5.3
Jul 11, 2016 @ 16:03:49

In his continuing series of posts looking at the new features in Laravel 5.3, Matt Stauufer has posted this guide to the use in the new JSON column functionality MySQL now provides in recent versions.

While Laravel has had the ability to cast your data to and from JSON since version 5.0, it was previously just a convenience—your data was still just stored in a TEXT field. But MySQL 5.7 introduced an actual JSON column type.

Laravel 5.3 introduces a simple syntax for lookups and updates based on the value of specific keys in your JSON columns.

He gives an example of a simple table with a JSON column storing some metadata for the entry. He includes a bit of example content showing the full entry and related metadata and the where format for querying it. It also includes the ability to run updates on the data just like with any other where clause.

tagged: laravel jon column mysql tutorial series part5 feature

Link: https://mattstauffer.co/blog/new-json-column-where-and-update-syntax-in-laravel-5-3

MaltBlue.com:
ZendDbSqlSelect - The Basics (Columns, Limit & Order)
Jul 02, 2013 @ 14: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 @ 18: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 @ 13: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 @ 17: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 @ 15: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 @ 23: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:


Trending Topics: