Combining two fields data into one field in the same database table

If you only want to display the name after combining the fields then simply use:
SELECT CONCAT(first_name, ‘ ‘, last_name) AS full_name FROM table_name;

But if you want to save them in a separate db field then use UPDATE query. To update all the records in the table in one shot use:

UPDATE table_name SET full_name = CONCAT(first_name, ‘ ‘, last_name);

Advertisements

Symfony Coding Standards Tips

Structure:

  • Never use short tags (<?);
  • Don’t end class files with the usual ?> closing tag;
  • Indentation is done by steps of four spaces (tabs are never allowed);
  • Use the linefeed character (0x0A) to end lines;
  • Add a single space after each comma delimiter;
  • Don’t put spaces after an opening parenthesis and before a closing one;
  • Add a single space around operators (==, &&, …);
  • Add a single space before the opening parenthesis of a control keyword (if, else, for, while, …);
  • Add a blank line before return statements, unless the return is alone inside a statement-group (like an if statement);
  • Don’t add trailing spaces at the end of lines;
  • Use braces to indicate control structure body regardless of the number of statements it contains;
  • Put braces on their own line for classes, methods, and functions declaration;
  • Separate the conditional statements (if, else, …) and the opening brace with a single space and no blank line;
  • Declare visibility explicitly for class, methods, and properties (usage of var is prohibited);
  • Use lowercase PHP native typed constants: false, true, and null. The same goes for array();
  • Use uppercase strings for constants with words separated with underscores;
  • Define one class per file;
  • Declare class properties before methods;
  • Declare public methods first, then protected ones and finally private ones.

Continue reading

Integrate the image upload feature in TynyMCE wysiwyg editor using IMCE Drupal module

In Drupal, by default the TynyMCE editor is allowing to insert the image URL only and not allowing to upload the images from front-end editors.

You need to add and configure some third party modules to achieve this functionality:

Following Drupal modules are required for it:

  • WYSIWYG – offers an API for implementing a variety of WYSIWYG editors including FCKeditor 2.6, jWYSIWYG 0.5, markItUp 1.1.5, NicEdit 0.9.0, openWYSIWYG 1.4.7, TinyMCE 3, TinyMCE 2, Whizzywig 55, WYMeditor 0.5, YUI editor 2.7.0
  • IMCE – IMCE is an image/file uploader and browser that supports personal directories and quota.
  • IMCE Bridge – This module is acts as a bridge between the IMCE module and the Wysiwyg module.

Continue reading

Drupal Tips and Tricks

Drupal admin and configuration:

  1. Create a “HTML help” block and assign it to appear on only “node/*/edit” and “node/add/*”
  2. Use the “edit permissions” link on admin/user/roles to get a single column
  3. Use the Firefox Web Developer Toolbar to “Populate Form Fields” on the access page for the admin role
  4. Use “site:drupal.org {search terms}” to search all of drupal.org withGoogle. Set up a Firefox shortcut so you can type “dru [your search]” tosearch Drupal. Also api.drupal.org/apis/{search_term}
  5. When using pathauto to alias usernames, don’t let users change their usernames.
  6. Use PathAuto and Path Redirect together to redirect old aliases to the new ones. Search engines will love you.

Continue reading

How to resolve the Drupal’s Clean URL disabled issue

Most of the time in Drupal the clean url setting in admin section is now allowing to enable/disable the clean UR’s.  It is totally unfocused.

This issue is not with the Drupal, this is because of wrong server configuration or .htaccess file. You can get rid of this issue by doing following steps.

1. Check the AllowOverride in httpd.conf is set to All

2. If you are using symbolic links then make sure that Options FollowSymLinks is uncommented.

3. Make sure that  Options Indexes FollowSymLinks is on in document root setting section. If you have written MultiViews in-front of this line then you should remove it because it overrides the mod_rewrite rules.

4.  Check .htaccess file is exist or not in drupal installation.

How to call a javascript function after pressing enter key in input box

If you got the errors in IE browsers after calling some Javascript
functions on input box event, then user the following methodology
to get rid of it:

<input type="text" id="txtSearch" 
onkeydown="if (event.keyCode ==13) document.getElementById('btnSearch').click()"/>

<input type="button" id="btnSearch" value="Search"
onclick="doSomething();" />