Wednesday, August 2, 2017

Mysql Query for swapping value in same column of table

UPDATE tablename SET fieldname  = CASE
    WHEN fieldname  = 'Y' THEN 'N'
    WHEN fieldname   = 'N' THEN 'Y'
    ELSE fieldname
    END
WHERE fieldname  in ('Y','N')

Sunday, January 25, 2015

Makrain

This is my village near Dehri on sone:
Situated at Bank of Sone River, East of Rohtas Industry(Dalmianagar):
North of G. T. Road


Dehri, also known as Dehri on Sone, is a city and a municipality in Rohtas district in the state of BiharIndia. It is a sub-division under Patna division and headquarters of the Bihar Military Police (BMP-2) as well as The Police headquarters of the Sahabad Range. Dehri is well connected by road and rail and has own airbase. It has a literacy rate of 83.38%, higher than the national average of 74.04% as per census 2011.

From Wikipedia, the free encyclopedia


Geography

Surya Mandir Makrain
Makrain, Dehri lies on the bank of the Sone River with an average elevation of 99 metres (324 feet). It has a Railway station on the Gaya-Mughalsarai section of Grand Chord railways route. Until 1984, it had three railway stations. There were two separate railway stations called Dehri-on-Sone and Dehri – one for narrow gauge Dehri Rohtas Light Railway and one for the Grand Chord Line.During British period, the Dehri on sone, station was called "Sone east Bank" by East Indian Railways [EIR].The two railway stations had no rail link because of the gauge difference and were separated by a road called Station road. The third station, Dehri City Railway station, was situated at the centre of the town on Dehri-Rohtas light Railway route. The Grand Trunk Road/शेर शाह सूरी मार्ग (NH 2) passes through the heart of the town. Dalmianagar, an industrial town is close to Dehri. Dehri is also called Dehri-On-Sone and sometimes combined as Dehri-Dalmianagar. The main occupation of the local population is agriculture – principally rice. Limestone,and sand (from the river bed of Sone rever).

http://wikimapia.org/21820041/Makrain


Thursday, June 6, 2013

PHP_Trainer_Online_Tutor

bhupendra
PHP & MySQL Course Curriculum
HTML
Introduction to HTML
HTML Documents
Structural Elements Of HTML Documents
Formatting HTML Documents
Managing Images In HTML
Tables In HTML Documents
Hypertext And Link In HTML Documents
Special Effects In HTML Documents
Multimedia
Managing Forms
Introduction to PHP
The Origin of PHP
PHP is better than Its alternatives
Interfaces to External systems
How PHP works with the Web Server
Hardware and Software requirements
What a PHP script looks like
Saving data for later
Receiving user input
Repeating code
Basic PHP Development
How PHP scripts work
Basic PHP syntax
PHP data types
Displaying type information
Testing for a specific data type
Changing type with Set type
Operators
Variable manipulation
Dynamic variables
String in PHP
Control Structures
The if statement
Using the else clause with if statement
The switch statement
Using the ? operator
The while statement
The do while statement
The for statement
Breaking out of loops
Nesting loops
Summary
Functions
What a function
Defining a function
Returning value from function
User-defined functions
Dynamic function calls
Variable scope
Accessing variable with the global statement
Function calls with the static statement
Setting default values for arguments
Passing arguments to a function by value
Passing arguments to a function by reference
Testing for function existence
Arrays
Single-Dimensional Arrays
Multidimensional Arrays
Casting Arrays
Associative arrays
Accessing arrays
Getting the size of an array
Looping through an array
Looping through an associative array
Examining arrays
Joining arrays
Sorting arrays
Sorting an associative arrays
Disk Access, I/O, Math And Mail
HTTP connections
Writing to the browser
Getting input from forms
Output buffering
Session handling
Regular expression
Common math
Random numbers
File upload
File download
Environment variables
E-mail in PHP
Cookies
The anatomy of a cookie
Setting a cookie with PHP
Deleting a cookie
Creating session cookie
Working with the query string
Creating query string
Session
What is session
Starting a session
Working with session variables
Destroying session
Passing session IDs
Encoding and decoding session variables
Working With The File System
Creating and deleting a file
Reading and writing text files
Working with directories in PHP
Checking for existence of file
Determining file size
Opening a file for writing, reading, or appending
Writing Data to the file
Reading characters
Working With Forms
Forms
Super global variables
The server array
A script to acquire user input
Importing user input
Accessing user input
Combine HTML and PHP code
Using hidden fields
Redirecting the user
File upload and scripts
Working With Regular Expressions
The basic regular expressions
PCRE
Matching patterns
Finding matches
Replace patterns
Modifiers
Breakup Strings
Classes And Objects
Objects oriented programming
Define a class
An Object
Creating an object
Object properties
Object methods
Object constructors and destructors
Class constants
Class inheritance
Abstract classes and methods
Object serialization
Checking for class and method existence
Exceptions
Iterators
Summary
Introduction To Database
Introduction to SQL
Connecting to the MYSQL
Selecting a database
Finding out about errors
Adding data to a table
Acquiring the value
Finding the number of rows
Inserting data
Entering and updating data
Executing multiple queries
jQuery
Introduction to jQuery
Syntax
Selectors
Events
Effects
Callback
HTML
CSS
Reference
Selectors
Events
AJAX with jQuery
Joomla
Introduction to Joomla
Installation of Joomla
Template Management
Menu Management
Structure of Modules & Components
ZEND
MVC
Infrastructure
Internationalization
Authentication and Access
Performance
Forms
Security
Diagnosis and Maintainability
Filtering and Validation
search
Database
Mail
Coding Standards
Web Services

Tuesday, June 4, 2013

Zend Interview Questions and Answers

Is Zend Framework a component library or a framework?

ZF is both. Zend Framework provides all the components required for most web applications in a single distribution. But Zend Framework components are also loosely coupled, making it easy to use just a few components in a web application- even alongside other frameworks! Using this use-at-will architecture, we are implementing features commonly found in more monolithic frameworks. In fact, we are currently working on a tooling component for the 1.8 release that will make it simpler to build applications using ZF components, yet will not sacrifice the use-at-will nature of existing ZF components.

What is autoloader?
Autoloader is function that load all the object on start up.

What is use of Zend front controller?
Routing and dispatching is managed in the front controller. It collects all the request from the server and handles it.

What is the use of Bootstrap?
Apart from index if we want to do any extra configuration regarding database and other things that is done within bootstrap.

How you can set Module name, Controller name, and Action name in Zend framework?
  •  $request->setModuleName(‘front’);
  •  $request->setControllerName(‘address’);
  •  $request->setActionName(‘addresslist’); 

Configuration in Zend Framework, application.ini file?
Configuration can be done in application.ini file in Zend framework. This file in the path application/configs/application.ini.

Checking whether form posted or not in Zend framework?
$request = $this->getRequest();
$getData = $request->getParams();
$postData = $request->getPost(); 
$isPost = $request->isPost();


Fetch last inserted id, fetch all record,find and fetch a single record.
$this->_db->lastInsertId();
$this->_db->fetchAll($sql);
$this->_db->find($id);
$this->_db->fetchRow($sql);

Difference between Zend_Registry and Zend_Session?

Zend_Registry is used to store objects/values for the current request. In short, anything that you commit to Registry in index.php can be accessed from other controllers/actions (because EVERY request is first routed to the index.php bootstrapper via the .htaccess file). Config parameters and db parameters are generally prepped for global use using the Zend_Registry object.

Zend_Session actually uses PHP sessions. Data stored using Zend_Session can be accessed in different/all pages. So, if you want to create a variable named ‘UserRole’ in the /auth/login script and want it to be accessible in /auth/redirect, you would use Zend_Session.

When do we need to disable layout?
At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);


How to call two different views from same action?
Example1:
Public function indexAction() {
If(condition)
$this->render(‘yourview.phtml’);
Else
Index.phtml;

Example2:
Public function indexAction() {
}
Now in your index.phtml you can have this statement to call other view
$this->action(‘action name’,’controller name’,’module name’,array(‘parameter name’=>’parameter value’));

Can we call a model in view?
Yes, you can call a model in view. Simple create the object and call the method. 
$modelObj = new Application_Model_User();

Can we rename the application folder ?
yes, we can

Can we move the index.php file outside the public folder?
yes, we can

How to include js from controller and view in zend?

From within a view file: $this->headScript()->appendFile(‘filename.js’);
From within a controller: $this->view->headScript()->appendFile(‘filename.js’);
And then somewhere in your layout you need to echo out your headScript object:
<?=$this->headScript();?>


How to include css from controller and view in zend? 
From within a view file: $this->headLink()->appendStylesheet(‘filename.css’);
From within a controller: $this->view->headLink()->appendStylesheet(‘filename.css’);
And then somewhere in your layout you need to echo out your headLink object:
<?=$this->headLink();?>

How do you protect your site from sql injection in zend when using select query?

We have to quote the strings,
$this->getAdapter ()->quote ( <variable name> );
$select->where ( ” <field name> = “, <variable name> );
OR (If you are using the question mark after equal to sign)
$select->where ( ” <field name> = ? “, <variable name> );

What is zend framework?
Answer: It is opensource framework created by zend.com (PHP company). It is object oriented and follow the MVC. Zend Framework is focused on building more secure, reliable and fast development.

How to add extra HTML (i.e link) in Zend_Form?
Answer: use Desciption decorator with (escape =false in second parameter).

How can I detect if an optional file has been uploaded?
Answer:  Zend_File_Transfer_Adapter_Http's receive()  return true.

What is Zend registry?
Answer: It is container for object and values  in applications, when you set an object in zend_registry you can access in whole site.

What is Zend_Form?
Answer: It is mainly used to display the form. but along with this we use for filter, validation and formating our form. It have following elements
Element filter
Element validation
Element ordering.
Decorator
Grouping
Sub form
Rendering form elments in single call or one by one for elements.

What is zend helpers?
It can be divided in two parts,
a) Action Helper: the helper is created for controller
b) View Helper: the helper is created for view files (.phtml).


What do you know about zend layout.
Answer: It work as a site template and have following features.
                Automatic selection and rendering layout
                Provide separate scope for calling element i.e parital, render, partialLoop

What is Inflection?
Answer: It is class in zend used to modify the string like convert to lowercase, change to url by removing special chars and convert underscore to hyphen.

What is Front Controller?
Answer:  It used Front Controller pattern.  zend also use singleton pattern.
routeStartup: This function is called before Zend_Controller_Front calls on the router to evaluate the request.
routeShutdown: This function  is called after the router finishes routing the request.
dispatchLoopStartup: This is called before Zend_Controller_Front enters its dispatch loop.
preDispatch: called before an action is dispatched by the dispatcher.
postDispatch: is called after an action is dispatched by the dispatcher.

What is Zend_filter?
Zend_filter is used to filter the data as remove the tags, trailing the spaces, remove all except digits.

Difference between Zend_Registry and Zend_Session




The use of these objects was confusing to me at first.. The basic difference between these objects is the ‘scope’ in which they are valid: 

a) Zend_Registry : request scope
b) Zend_Session : session scope

Zend_Registry is used to store objects/values for the current request. In short, anything that you commit to Registry in index.php can be accessed from other controllers/actions (because EVERY request is first routed to the index.php bootstrapper via the .htaccess file). Config parameters and db parameters are generally prepped for global use using the Zend_Registry object.

Zend_Session actually uses PHP sessions. Data stored using Zend_Session can be accessed in different/all pages. So, if you want to create a variable named ‘UserRole’ in the /auth/login script and want it to be accessible in /auth/redirect, you would use Zend_Session.

Monday, April 29, 2013

Configure wamp for windows 7

Configure wamp for windows 7

1) ;short_open_tag = Off

REPLACE TO THIS---------------------

short_open_tag = On

2);error_reporting(E_ALL ^ E_DEPRECATED);

 REPLACE TO THIS---------------------------

error_reporting = E_ALL & ~E_NOTICE  & ~E_WARNING & ~E_DEPRECATED



3)rewrite_module




-------------------------------------------------------------------------------
Must be checked in php.ini file

Than Restart Your Wamp Server................

Wednesday, April 3, 2013

What is InnoDB and ACID in DBMS.

bhupendra
bhupendra
ACID
*Atomicity states that database modifications must follow an “all or nothing” rule. Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. It is critical that the database management system maintain the atomic nature of transactions in spite of any DBMS, operating system or hardware failure.
* Consistency states that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules. On the other hand, if a transaction successfully executes, it will take the database from one state that is consistent with the rules to another state that is also consistent with the rules.
* Isolation requires that multiple transactions occurring at the same time not impact each other’s execution. For example, if Joe issues a transaction against a database at the same time that Mary issues a different transaction, both transactions should operate on the database in an isolated manner. The database should either perform Joe’s entire transaction before executing Mary’s or vice-versa. This prevents Joe’s transaction from reading intermediate data produced as a side effect of part of Mary’s transaction that will not eventually be committed to the database. Note that the isolation property does not ensure which transaction will execute first, merely that they will not interfere with each other.
* Durability ensures that any transaction committed to the database will not be lost. Durability is ensured through the use of database backups and transaction logs that facilitate the restoration of committed transactions in spite of any subsequent software or hardware failures.
infinititsolutions


=============================InnoDB=================================
InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints. You can freely mix InnoDB tables with tables from other MySQL storage engines, even within the same statement.