Tuesday, October 4, 2011

List out some hook function in drupal

hook_access->Define access restrictions.
hook_auth->Verify authentication of a user.
hook_block->Declare a block or set of blocks.
hook_comment ->Act on comments.
hook_cron->Perform periodic actions.
hook_db_rewrite_sql ->Add JOIN and WHERE statements to queries and decide whether the primary_field shall be made DISTINCT. For node objects, primary field is always called nid. For taxonomy terms, it is tid and for vocabularies it is vid. For comments, it is cid. Primary...
hook_delete->Respond to node deletion.
hook_elements->Allows modules to declare their own form element types and specify their default values.
hook_exit->Perform cleanup tasks.
hook_file_download ->Allow file downloads.
hook_filter->Define content filters.
hook_filter_tips->Provide tips for using filters.
hook_footer->Insert closing HTML.
hook_form->Display a node editing form.
hook_form_alter->Perform alterations before a form is rendered. One popular use of this hook is to add form elements to the node form.
hook_help->Provide online user help.
hook_info->Declare authentication scheme information.
hook_init->Perform setup tasks.
hook_insert->Respond to node insertion.
hook_install->Install the current version of the database schema.
hook_link->Define internal Drupal links.
hook_load->Load node-type-specific information.
hook_menu->Define menu items and page callbacks.
hook_nodeapi ->Act on nodes defined by other modules.
hook_node_grants->Grant access to nodes.
hook_node_info->Define the human-readable name of a node type.
hook_perm->Define user permissions.
hook_ping->Ping another server.
hook_prepare ->This is a hook used by node modules. It is called after load but before the node is shown on the add/edit form.
hook_search->Define a custom search routine.
hook_search_preprocess->Preprocess text for the search index.
hook_settings->Declare administrative settings for a module.
hook_submit->This is a hook used by node modules. It is called after validation has succeeded and before insert/update. It is used to for actions which must happen only if the node is to be saved. Usually, $node is changed in some way and then the actual saving of...
hook_taxonomy->Act on taxonomy changes.
hook_update->Respond to node updating.
hook_update_index->Update Drupal's full-text index for this module.
hook_update_N->Perform a single update. For each patch which requires a database change add a new hook_update_N() which will be called by update.php.
hook_user->Act on user account actions.
hook_validate ->Verify a node editing form.
hook_view->Display a node.
hook_xmlrpc->Register XML-RPC callbacks.
module_hook->Determine whether a module implements a hook.
module_implements->Determine which modules are implementing a hook.
module_invoke->Invoke a hook in a particular module.
module_invoke_all->Invoke a hook in all enabled modules that implement it.

List out some functions in template.php

phptemplate_body_class($left, $right)
phptemplate_breadcrumb($breadcrumb)
phptemplate_preprocess_page(&$vars)
garland_preprocess_comment_wrapper(&$vars)
phptemplate_menu_local_tasks()
phptemplate_comment_submitted($comment)
phptemplate_node_submitted($node)
phptemplate_get_ie_styles()

theme_preprocess_node(&$vars) {
theme_preprocess_page(&$vars) {
theme_preprocess_block(&$vars) {
theme_filter_tips_more_info()
theme_filter_tips()
theme_button($element) {

Monday, October 3, 2011

Diff between UNSET and UNLINK.

unlinkDeletes a file

unset — Unset a given variable

List out curl functions in PHP

The following function are used to call CURL in php,
curl_init() - Initialize a cURL session
curl_setopt() - Set an option for a cURL transfer
curl_exec() - Perform a cURL session
curl_close() - Close a cURL session
curl_errno() - Return the last error number
curl_error() - Return a string containing the last error for the current session
curl_version() - Gets cURL version information
curl_getinfo() - Get information regarding a specific transfer

Example:

$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

List out the drupal query functions

The following query functions are used in
db_connect - Initialize a database connection.
db_query - Execute query
db_result - Return an individual result field from the previous query.
db_affected_rows - Determine the number of rows changed by the preceding query.
db_rewrite_sql - Rewrites node, taxonomy and comment queries. Use it for listing queries
db_create_table -Create a new table from a Drupal table definition.
db_field_names - Return an array of field names from an array of key/index column specifiers.
db_query_range - Runs a limited-range query in the active database.
db_fetch_array - Fetch one result row from the previous query as an array
db_fetch_object - Fetch one result row from the previous query as an object.
db_error - Determine whether the previous query caused an error.
db_lock_table - Lock a table.
db_unlock_tables - Unlock all locked tables.
db_table_exists - Check if a table exists.
db_column_exists - Check if a column exists in the given table.

Manage MySQL using shell scripting.

Connect MySQL : mysql -h -u -p
Create a DB: mysql> create database
Use a DB for operate: mysql> use
Show all databases: mysql> show databases;
Show the running quries: mysql> process list
Kill the query: mysql> kill