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

Evert Pot:
MySQL 5.6 BOOL behavior when using PDO and prepared statements
December 05, 2013 @ 10:37:42

Evert Pot was seeing some weird issues with his MySQL BOOL usage via PDO when he upgraded to one of the latest versions (5.6). Thankfully, he's shared his solution to the problem as well as the symptoms he was seeing when it was causing problems.

I recently updated my workstation to run MySQL 5.6.13. It didn't take very long for things to start breaking, and since I couldn't find any other information about this on the web, I figured this may be useful to someone else. The main error that started popping up was: "Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'my_bool' at row 1' in test.php" This exception happens under the condition that you use PDO, prepared statements and booleans.

He includes a small sample script to reproduce the issue and points out the issue - the default casting of prepared values to strings in prepared statements with PDO bound parameters. He shows two "relatively easy solutions" to the problem - either using integers instead of the true/false PHP boolean or specifying a type with the bindValue call.

0 comments voice your opinion now!
mysql upgrade boolean field pdo prepared statement

Link: http://evertpot.com/mysql-bool-behavior-and-php/

MaltBlue.com:
Zend Framework 2 - The New HTML5 Form Fields - Part 2
July 12, 2013 @ 13:41:56

Matthew Setter has posted the second part of his look at the HTML5 form support that comes with Zend Framework 2. In this new post, he focuses on a few different fields - month, range, color, week and number.

Owing to the overwhelming popularity of the first post on the new HTML5 fields in Zend Framework 2 here on Malt Blue, it's only right to have a follow up, covering the other available elements. [...] To really show just how effective using these new elements is, each code snippet had an accompanying screenshot of the element, rendered in iOS on iPhone.

He includes examples for each of the element types including a small screenshot and the code needed to create it. They show how to create the elements and define the custom attributes (like the range for a "Number" field or the date range for a "Week").

0 comments voice your opinion now!
zendframework2 form field html5 series introduction

Link: http://www.maltblue.com/php/html5-form-fields-in-zend-framework-2-part-2

Ian Christian's Blog:
Creating a custom form field type in Symfony 2
August 16, 2011 @ 12:04:37

Ian Christian has added a new post to his blog today showing how you can create a custom form field type in Symfony 2 by extending the AbstractType.

I am finally starting to dive into symfony 2 properly. Yes - it's taken a while, work has taken me in different directions! I found myself needing to create a custom form field type pretty quickly, but couldn't find much in the way of documentation to do so, so I thought I'ld throw it up here; partly to help others, but mostly to get feedback to make sure I'm not approaching this from the wrong angle.

He includes the code that creates his custom "Person" model and the class to create his "transport type" select box that pulls in its values from a "choice list" class. He registers it in his bundle and it can then be included in his buildForm() method just like any other form field.

0 comments voice your opinion now!
symfony tutorial custom form field select abstract


AjaxRay.com:
Extending Zend Form Element to create customized Phone number field
September 02, 2010 @ 08:05:06

On the AjaxRay.com site today there's a new tutorial for the Zend Framework users out there with a library they can use to extend Zend_Form for custom phone number fields.

When taking Phone number as user input, we can worn users about phone number format by setting a hint/description and can validate using Regular Expression. [...] Now, if we try provide this feature in Zend Form, that's possible. We can create three individual Zend_Form_Element_Text objects and join there value together to make the phone number. But, in this case, validating them together is a hassle.

Instead of separate fields, the library they create makes it simple to handle them as a whole field. It works as a helper for Zend_Form and lets you set things like the separator between the text fields, a "format" string and a validator to apply to their fields (in the example code, it's the "digits" validator). Sample code is included to show you how it fits in your form.

0 comments voice your opinion now!
zendform extend phone number custom field tutorial


Zend Developer Zone:
Building AutoComplete Inputs with PHP, PEAR, Dojo and YUI
February 04, 2009 @ 15:29:25

The Zend Developer Zone has a new tutorial posted (from Vikram Vaswani) about adding in an auto-complete input field to your site. His example uses a PEAR class, Dojo and some components of the YUI libraries.

Fortunately, modern programming toolkits like Dojo provide ready-made widgets that have the necessary client-side functions for autocomplete. Add a little bit of server-side glue, in the form of a PHP script that talks to a database to generate valid suggestions, and enabling this functionality in a Web application now becomes a matter of hours, rather than days. In this article, I'll show you how to do this using three different libraries: PEAR HTML_QuickForm, YUI, and Dojo. Come on in, and find out more!

He shows how to combine Dojo, YUI and the HTML_QuickForm PEAR package to create a field that, based on what they enter into the input field, searches a database to find values in that table.

0 comments voice your opinion now!
autocomplete input field tutorial yui dojo pear htmlquickform


Mike Bernat's Blog:
CakePHP - Changing the Default Value of a Date-Time Input
December 10, 2008 @ 07:54:44

In a recent post to his blog Mike Bernat gives a quick tip on how to change the default value of a data-time input field in a CakePHP application.

Automagically generated date/time input fields normally default to the current date and time. For a couple of reasons, I had to change this to another default value.

His included code shows how to modify the default behavior of the form input field for the date with an array of parameters including the hour, minute and meridian (am/pm) values for the element.

0 comments voice your opinion now!
cakephp datetime form field custom default value


Vinu Thomas' Blog:
Quicker and cleaner Form using Zend Form
February 13, 2008 @ 08:56:00

On his blog today, Vinu Thomas has an example of what he calls a "quicker and cleaner form" using the Zend_Form component of the Zend Framework.

Usually handing forms involves coding the form in HTML and performing client and server side validation, which usually makes the code for complex forms quite unwieldy. Zend_Form which is available in Zend Framework version 1.5 aims at simplifying this process.

With this new version comes the ability to add in methods for validation right into the form definition. His example shows a traditional login form that checks things like if it's required, checking the length and adding filters to modify the input.

0 comments voice your opinion now!
zendframework zendform validate field definition


Chris Hartjes' Blog:
Simple User Registration in CakePHP 1.2, Part II
January 23, 2008 @ 09:36:00

Chris Hartjes has followed up on a previous post about user authentication in CakePHP with a few more comments in part two.

I got a question in the comments about my previous post on simple user registration about how to do some of the necessary validation for registration in the model. I thought I'd show some code I did to do exactly that.

He includes the code for his example with the key, he explains, being the use of a second field (the confirm password field) to do the validation.

0 comments voice your opinion now!
user registration cakephp validation confirm field


Tim Koschuetzki's Blog:
How to put Combined Fields Into CakePHP's Model->generateList()
August 10, 2007 @ 09:36:00

Tim Koschuetzki has posted this tutorial today about how to create form fields with combined information from more than one database column.

Two days ago, someone on #cakephp had the problem of getting combined values out of the Model->generateList() function in CakePHP. I advised him on doing some Set::extract() things, which at the end of the day got rather complicated. As a result, I was conscience-stricken. Here is a much more elegant solution I could come up with.

He introduces the generateList function first, showing how to use it to create a simple select list in your form. Unfortunately, it only understands using one field at a time, so he worked around it, creating a solution - his myGenerateList function - that handles things similarly and returns the same kinds of results (so it can be used with the set() function as well).

0 comments voice your opinion now!
combined field data database cakephp framework generatelist combined field data database cakephp framework generatelist


The Bakery:
New Articles/Tutorials - NiceHead, Field Validation and Plugin Paths
May 15, 2007 @ 11:53:00

The Bakery has three new items posted today - a view helper for CSS/JS file inclusion, field validation, and rewriting a plugin's paths:

Check out these and more great CakePHP-related tutorials on The Bakery!

0 comments voice your opinion now!
nicehead field validation cakephp framework plugin path nicehead field validation cakephp framework plugin path



Community Events





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


development framework series threedevsandamaybe list release introduction tips api deployment laravel bugfix podcast zendserver interview conference code community symfony language

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