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

SitePoint PHP Blog:
Social Network Authentication: Merging Accounts
Jul 16, 2014 @ 17:19:07

The SitePoint PHP blog continues their series looking at authenticating your application against other social networking services with this new post discussing the merging of accounts. This merging allows you to determine if the same user is using more than one account to log into your system.

If you allow users to sign up through different social networks and perhaps your own registration system, there is a good chance some users will have multiple accounts. How annoying can it be for a user who signed up through Facebook earlier, to come back later and log in through Twitter because he thought he used that one? We can prevent this by letting the user merge manually or try to use an automatic system to try and identify duplicated users.

He tracks the information about the users in two different database tables, one for the user themselves and another representing that user's provider (the social network). He gives an overview of two methods you could use for merging these accounts: either doing it manually by suggesting it to the user or trying to do it automatically based on the data you already have.

tagged: social network authentication tutorial series merge accounts

Link: http://www.sitepoint.com/social-network-authentication-merging-accounts/

Leve.rs:
Array Manipulation in PHP, the Correct Way
Nov 08, 2013 @ 16:08:04

On the Leve.rs blog there's a recent post showing what they consider is the right way to work with arrays in PHP. It shows three things you can do to use PHP's own functionality to more correctly perform some common array operations.

More often than not, when PHP developers debug others’ code, the majority of each method is taken up by array manipulations. Spending this much time on array manipulations is a huge hassle when trying to understand any given method. In order to speed up the debugging process, it’s important to start writing array manipulations the correct way, first. Here are a few examples of code I have either written myself or had to fix in the past. It is time every PHP developer knows how to manipulate arrays properly!

Their three tips relate to:

  • Merging Arrays
  • Array Value Manipulation (with array_walk)
  • Array Value Manipulation (append with the plus sign, "+")
tagged: array manipulation correct merge value walk plus

Link: http://leve.rs/blog/correct-array-manipulation-in-php/

Community News:
phpDocumentor Merges with DocBlox for phpDocumentor 2!
Mar 16, 2012 @ 12:58:00

As is mentioned in this new post to the DocBlox blog, there's been a major development between it and the phpDocumentor documentation generation tool - phpDocumentor 2 will be released soon, merging DocBlock and phpDocumentor into one tool!

Announcing phpDocumentor 2 – the merging of the old (phpDocumentor) and the new (DocBlox). With the first alpha release of phpDocumentor (2.0.0a1), the new “Responsive” default template sports a new page layout, along with the useful layout improvements that the original DocBlox templates provided (which remain available) over the old phpDocumentor templates (which will retire with old phpDocumentor). Explore this new template at http://demo.phpdoc.org/Responsive/index.html.

Users of the current phpDocumentor software (version 1.x) will need to upgrade their documentation and installations. If you'd like more information about the transition or just keep up with the latest on this exciting advancement, check out #phpdocumentor on Freenode IRC or follow @phpdocumentor on Twitter.

tagged: phpdocumentor merge docblox documentation automatic project

Link:

Gustav Eklundh' sBlog:
Search Methods in PHP
Aug 01, 2008 @ 18:45:22

Gustav Eklundh has posted a whole series of search type implementations to his blog - here's the list so far:

He briefly explains each of the sort methods in each of the posts, sometimes with links to external sources (like Wikipedia) for more information on the method.

tagged: search method quicksort strand merge gnome

Link:

Blog.szajbe.pl:
Not so obvious behavior of $uses in CakePHP
Jul 09, 2008 @ 17:02:41

In this new post to the blog.szajbe.pl site a dilemma is presented - CakePHP models are not working they way one would think they should.

In CakePHP you declare what models you're going to use in a controller by defining $uses variable. You can also define it in AppController to have a certain set of models available in every controller. However be careful when doing it because you may put yourself in an unexpected situation as I did recently.

As soon as he made his script include a 'User' model in every quest, his logins stopped working. His script errored with a "Database table sessions for model Session was not found" message and refused to work. Digging deeper, he found that CakePHP merges an AppController's $uses value with the SessionControler's values. One overrides the other and your 'User' gets lost in the shuffle.

Do you have a rational explanation for such behavior? I have none. It's very unintuitive for me.
tagged: cakephp model behavior user login appcontroller sessioncontroller merge uses

Link:

John Highland's Blog:
LifeStreaming Is Simple As Pie
Apr 25, 2008 @ 17:56:33

John Highland has a quick tutorial showing how to create a lifestream with PHP out of all of the RSS feeds surrounding the multiple social networking and blogging sites you have out there (with the help of SimplePie).

Its not secret, I love social networking, I cant get enough of it. I also love programming and anything internet related. I'm not sure how I came across it, but a PHP based, Object Oriented RSS caching tool named SimplePie caught my attention.

SimplePie offers one piece of functionality that he found particularly useful - the ability to merge RSS feeds easily. He took advantage of the ability and pulled together his Twitter, Flickr, Pownce, Digg and Youtube RSS feeds to make one mega-feed. You can see an example of it in action over on his personal site.

tagged: lifestream simplepie rss feed combine merge tutorial

Link:

Brian Moon's Blog:
Responsible use of the $_REQUEST variable
Jan 22, 2008 @ 15:38:00

In one of his recent blog entries, Brian Moon takes a look at what he considers the "proper use" of the PHP superglobal $_REQUEST (as brought on by a thread on the PHP internals mailing list.

I have seen more than one person make the following logic mistake: I may get data via GET, I may get data via POST - Ah, I should use $_REQUEST as it will catch both.

Brian points out the error - cookies aren't in $_REQUEST so improper handling of those values could lead to cookie data overwriting GET/POST data from $_REQUEST. Several of the comments on the post also warn against improper handling of the values, noting that doing so could lead to holes open for attacks (like session fixation).

tagged: get post request superglobal cookie security merge

Link:

Felix Geisendorfer's Blog:
New fix for array junkies: Set::merge assembles yummy arrays
Apr 06, 2007 @ 14:29:00

In a new post today, Felix Geisendorfer shares a method for merging together nested arrays correctly with a little help from functionality in the CakePHP framework.

Todays post features a brand new Set function called merge that was a side product of me working on a cool new cake class. If you've done a lot of array work in the past, you've probably have come in situations where you wanted to merge to arrays into a new one. Usually that's a no-brainer in PHP by simply using the array_merge function (or the CakePHP wrapper 'am'):

In about 90%++ of all cases, this will the usual way to merge two (or more) arrays into a new one. However, sometimes array_merge is not going to cut it. That'll mostly be because it does not behave recursive and merging nested arrays can lead to unexpected results.

He even shows an example of the use of array_merge_recursive to try to get his desired results. With that still not working, he turns to CakePHP to help him out. He comes up with the Set::merge method to handle the merging of the arrays in what he thinks is a "more correct" way.

tagged: merge array arraymerge arraymergerecursive cakephpframework merge array arraymerge arraymergerecursive cakephpframework

Link:

Felix Geisendorfer's Blog:
New fix for array junkies: Set::merge assembles yummy arrays
Apr 06, 2007 @ 14:29:00

In a new post today, Felix Geisendorfer shares a method for merging together nested arrays correctly with a little help from functionality in the CakePHP framework.

Todays post features a brand new Set function called merge that was a side product of me working on a cool new cake class. If you've done a lot of array work in the past, you've probably have come in situations where you wanted to merge to arrays into a new one. Usually that's a no-brainer in PHP by simply using the array_merge function (or the CakePHP wrapper 'am'):

In about 90%++ of all cases, this will the usual way to merge two (or more) arrays into a new one. However, sometimes array_merge is not going to cut it. That'll mostly be because it does not behave recursive and merging nested arrays can lead to unexpected results.

He even shows an example of the use of array_merge_recursive to try to get his desired results. With that still not working, he turns to CakePHP to help him out. He comes up with the Set::merge method to handle the merging of the arrays in what he thinks is a "more correct" way.

tagged: merge array arraymerge arraymergerecursive cakephpframework merge array arraymerge arraymergerecursive cakephpframework

Link:

Jonathan Snook's Blog:
Quick Merge in MySQL
Aug 22, 2006 @ 20:38:08

Jonathan Snook has a quick tip for PHPers out there using MySQL and looking for an easy way to concatinate a lot of data in your queries.

This is just a quick tip. If you have a bunch of data that you need to concatenate, take a look at MySQL's GROUP_CONCAT function.

For example, way back when, I wrote about (and subsequently weighting those tags) to an application. It was a very simple approach with each record having a tags field. It was just a simple text field and I stored all the tags with spaces. However, to pull out a list of all tags being used in the system, I returned the tags field from all records, looped through each record, exploding the tags onto an array.

Using the group_concat() function already in MySQL, he was able to reduce looping through his data, splitting on the spaces down to a single line call in SQL telling it to concatinate spaces. He includes the code (just a few lines) to get the job done.

tagged: quick merge sql group_concat simple quick merge sql group_concat simple

Link:


Trending Topics: