News Feed
Sections




News Archive
feed this:

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

NetTuts.com:
Understanding and Working with Data in WordPress
July 29, 2014 @ 11:28:05

On NetTuts.com there's a new post for those new to WordPress (or just wanting to figure out more about the internals of the tool) showing how some of the data is structured and how to work with it.

Most WordPress users never come into direct contact with the database and may not even be aware that it's constantly working to populate their site. When WordPress serves up any kind of page, be that the home page, a single post or page or an archive, it's accessing the database to bring up content that editors and administrators have added to the site. In this series of tutorials I'll look in detail at different aspects of the WordPress database.

This post is the first in the series and provides an overview of the database and what kinds of information each one contains. They talk about content types and provide the table structure and relations in a handy graphical form (an ERD). They then go through each of the tables and describe what the data is including link tables, joining the content in different places.

0 comments voice your opinion now!
data wordpress introduction database table erd overview

Link: http://code.tutsplus.com/tutorials/understanding-and-working-with-data-in-wordpress--cms-20567

Lee Davis' Blog:
The enum conundrum
July 06, 2012 @ 11:56:52

In a new post to his blog Lee Davis describes the enum conundrum - what's the right solution for effectively using ENUM-type fields in your data?

So a user signs up and I want to store a status that reflects their account, or at least an identifier representing that status. Their account could be active, disabled (temporarily), pending approval or maybe deleted. Should I use an enum? I've heard they're evil. Maybe having a reference table with statuses would be better? But now I have to manage a separate table just for that one snippet of data, is that overkill? Could I maybe use that status table for other entities? Or, could I instead just use an integer and reference it on the code level? What is the right solution?

He presents three of the most common situations he's seen for people using enums in the application:

  • "I used enums all over the place" (maintenance between code and DB values)
  • "use a reference table"
  • "I could use a class constant to represent the enum" (enforced in the app)

Of the three, he suggests the third as the option with the most advantages. Not only does it make it simpler to get the allowed values for the field, but you're also more flexible in the kinds of validation you can do on the values.

0 comments voice your opinion now!
enum conundrum reference table constant maintenance


Gonzalo Ayuso's Blog:
Building a simple SQL wrapper with PHP. Part 2.
June 18, 2012 @ 10:05:50

Gonzalo Ayuso has followed up his previous post about creating a simple SQL wrapper with PDO in PHP with this new post, a "part two" looking at improving it a bit with a new class to represent the tables.

In one of our last post we built a simple SQL wrapper with PHP. Now we are going to improve it a little bit. We area going to use a class Table instead of the table name. Why? Simple. We want to create triggers. OK we can create triggers directly in the database but sometimes our triggers need to perform operations outside the database, such as call a REST webservice, filesystem's logs or things like that.

He includes the updated code with the new "Table" class with methods that let you set up pre- and post-action hooks on each of the types (insert, delete, update) along with the rest of the library, there ready for the copy & pasting.

0 comments voice your opinion now!
sql wrapper tutorial table hook object


Liip Blog:
Table Inheritance with Doctrine
March 28, 2012 @ 09:30:09

On the Liip blog there's a recent post looking at table inheritance with Doctrine, the popular PHP ORM tool. In the post, Daniel Barsotti talks about a database model that needed some updating due to their searching needs.

Our first idea, and it was not that bad, Drupal does just the same, was to have a database table with the common fields, a field containing the type of item (it's either an event or a blog post) and a data field where we serialized the corresponding PHP object. This approach was ok until we had to filter or search LabLog items based on fields that were contained in the serialized data.

To resolve the issue they turned to multiple table inheritance, relating the LabLogItem to both a BlogPost and Event. They also show how it could be modeled with a single table, but opt for the multiple method. Included in the post is the Doctrine-based code showing how to create the parent entity for the LabLogItem and the two child entities for the blog post and event. There's also a brief snippet showing how to use them with the EntityManager.

0 comments voice your opinion now!
table inheritance doctrine orm tutorial multiple


Rob Allen's Blog:
One-to-Many Joins with Zend_Db_Table_Select
February 08, 2012 @ 09: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.

0 comments voice your opinion now!
onetomany database table join zendframework zenddb component


Developer Drive:
Building a PHP Ad Tracker Creating the Database Tables
January 16, 2012 @ 12:48:30

On Developer Drive today there's a new post (the first in a series) from Gerald Hanks about building an ad tracker in PHP. In this first part he sets up some of the background - the database that will hold the tracker information.

Banner ads for services related to the web site owner's industry allow customers to view products that tie into the site owner's core business. In exchange, the web site owner can charge the banner ad owner for every impression (banner ad appearance) or click-through (when a user clicks the banner ad). In order to build a banner ad management system, we must first create the database tables that will hold the ad information, the client data and the activity schedule for each ad.

He includes the SQL you'll need to create a few tables - the tracking table for the ads themselves (their metadata), the clients table to handle the groups wanting the ads and the activity table to track views and click-throughs.

0 comments voice your opinion now!
ad tracker database table tutorial clickthrough


Freek Lijten's Blog:
The real problem of the hash table dos attack
December 30, 2011 @ 12:53:35

In response to some of the comments being made about the hash table Denial of Service attack recently posted Freek Lijten has posted his thoughts about the real problem with the whole situation - how it was handled by the communities involved.

Interesting they may be, but I want to address what in my opinion is the real problem: The way the communication around it was handled by different projects and the fact that the exploit could still exist at all. [...] In the presentation Wälde and Klink talk about their disclosure process. The PHP project had them wait 3 weeks for a first response while this is obviously a serious matter.

He argues that things like a commit message mentioning a DoS prevention fix instead of just mentioning the fix have the potential to do more harm than good. He also points out that other communities were notified of the problem (like Python) and some still haven't responded to the issue.

This attack was the result of good research and it is important that it is disclosed. More importantly however is the fact that organisation got by with years of not noticing it and even worse, reacted very poor after being informed. I can't say I have a ready solution to avoid these kind of things in the future, perhaps that will prove to be an interesting discussion.
0 comments voice your opinion now!
dos attack hash table opinion community response


Developer Drive:
PHP User Survey Setting Variable Values and Reading from Tables
November 30, 2011 @ 11:04:33

The Developer Drive blog has the latest post in their "PHP User Survey" series focusing on setting up admin functionality for the poll managers to use.

In Part I of this series, we started the process of creating user polls for a business web site. Part I gave the layout of the data layer and began the construction of the class file. In this part we will continue with adding methods to the class file that will enable the administrator to set the variable values and read from the database tables.

Code is included for setting the poll and answer ID values (setters), grabbing the number of polls currently defined, finding the active ones and pulling out poll data along with its answers. If you need to catch up, you can find the other parts here: part one, part two.

0 comments voice your opinion now!
survey poll tutorial database table


Developer Drive:
Creating a PHP User Survey Writing to Database Tables
November 22, 2011 @ 14:54:03

On Developer Drive today they've posted the most recent article in a tutorial series showing you how to create a user survey that stores the results to a database table. In this latest tutorial, they show how to hook the current code into a MySQL backend.

In the first two parts of this series, we created the data layer that will hold the polling data and established methods for setting the variable values and reading from the database tables. In this part, we will build the methods that will write new polls and answers to the tables.

They include the code for an "addPoll" method that inserts the questions and answers for the polls. Their "editPoll" method updates the poll questions/answers and the "addVote" method does exactly like it sounds - adding a vote to one of the poll options. Also included are "deletePoll", "activatePoll" and "deactivatePoll".

0 comments voice your opinion now!
tutorial database table poll survey answers questions


php|architect:
Full-text Search with SQLite
November 15, 2011 @ 09:53:50

On the php|architect site there's a recent tutorial from Jeremy Kendall about full-text searching in SQLite, a lightweight database alternative that, since it's stored locally, can be used without a full database server.

Full-text search with SQLite is so ridiculously easy to implement, there are only two valid reasons you haven't done it yet. The first is you don't need the full-text capability, and the second is you didn't know it could be done.

In his method he creates a full-text search table (using fts4) and populating it with your data. You can use the "MATCH" keyword in your SQL to find the closest matches and even handy modifiers like "NEARBY", wildcards and token/prefixes in queries. For more detailed information, check out the SQLite documentation for a full guide.

0 comments voice your opinion now!
fulltext sqlite search fts4 table



Community Events





Don't see your event here?
Let us know!


laravel install wordpress code podcast release community application interview introduction series api bugfix developer list language symfony configure library threedevsandamaybe

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework