CheckMySQL Engine of databse table

For specific table:

SHOW TABLE STATUS WHERE Name = 'table_name';

For all tables of specific database:

SELECT TABLE_NAME,
ENGINE
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'database_name';

Or you can use this simple command, this will list all tables:

SHOW TABLE STATUS;

How to remove N/A from radio button options in drupal7?

How to remove N/A from radio button options in drupal7?

If you dont want to show the N/A option in the radio buttons option lists, than make that field mandatory.
When you make that field required it will remove the N/A option.

But if you dont want to make that field required and also dont want to show N/A option, then you use theme hook function
theme_form_element($variables) to alter that.

function mytheme_form_element($variables) {
$element = $variables['element'];
// Disable radio button N/A
if ($element['#type'] == 'radio' && $element['#return_value'] === '_none') {
$variables['element']['#attributes']['disabled'] = TRUE;
}
return theme_form_element($variables);
}

you can use your theme’s name in place of mytheme in function name, and add this function to your theme’s template.php file.

Hide using CSS:

.form-radios .form-disabled {
display: none;
}

OOP Introduction

Hello friends,

I am here to teach you Object oriented principles in very simple way.

Previously we were using functions only for more complex programs not object oriented method, and it worked, than why wee need to use OOP??

Because it contain variable and functions together in one unit, and its called object. and whole object oriented programming based on this object.

and containg the variable data and functions in one unit called the Encapculation.

for coding forget all length definations and keep these short terms in mind:

Class: a collection of vaiables and methods
Object: a thing or name
Instantiate: crating an object
Method: function of class
Property: variable of class

get drupal taxonomy term list using vocabulary

Get drupal 7 taxonomy term list using vocabulary machine name

function get_taxonomy_terms_by_vocabulary($vocabulary_machine_name){

$term_data = array();
$vid = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name)->vid;
$terms = taxonomy_get_tree($vid);

//If you want to get more custom fields value, than use
//$terms = entity_load('taxonomy_term', FALSE, array('vid' => $vid));

foreach($terms as $term){
$term_data[$term->tid] = $term->name;
}

return $term_data;
}

Submit drupal form & node_save using hook_submit_form in Drupal 7

function user_identity_form_submit($form, &$form_state) {
  global $user;
  global $base_url;
  //variable_set('identity_image', $form_state['values']['identity_image']);
  $file = file_load($form_state['values']['identity_image']);
  if($file){
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);
    file_usage_add($file, 'user_identity', 'user_identity', $file->uid);

    //create node identity
    $node = new stdClass();
    $node->type = 'user_identity';
    node_object_prepare($node);
    $node->title = 'Identity: '.$user->name;
    $node->field_photo_document['und'][] = (array)$file;
    $node->language = LANGUAGE_NONE;
    $node->uid = $user->uid;
    $node->status = 0;
    node_save($node);
...

Display image after upload using managed_file in Drupal 7

function MODULE_NAME_theme() {
    return array(
      'MODULE_NAME_image' => array(
        'render element' => 'form',
      ),
    );
}

function theme_MODULE_NAME_image($variables) {
    $form = $variables['form'];
    if(isset($form['#file']->uri))
        $form['identity_image']['#markup'] = theme('image_style', array('style_name' => 'thumbnail', 'path' => file_build_uri(file_uri_target($form['#file']->uri))));
    $output = drupal_render_children($form);
    return $output;
}

function MODULE_NAME_form($form, &$form_state) {
    $form = array();
        $form = array();
        $form['identity_image'] = array(
          '#title' => t('Upload photo document'),
          '#type' => 'managed_file',
          '#required' => true,
          '#upload_location' => 'public://identity/'.$order->uid.'/',
          '#upload_validators' => array(
            'file_validate_extensions' => array('jpg png jpeg'),
          ),
          '#theme' => 'MODULE_NAME_image',
        );
        $form['submit'] = array(
          '#type' => 'submit',
          '#value' => t('Approved'),
        );
return $form;
}