Nov
9
2012

ZEND HeadScript Helper

In  HTML  <script> element tag  is used to provide client-side scripting e.g  javascript or it points the external script file through src attribute. The HeadScript helper supports the following methods for setting and adding scripts: To put the script in a specific order we use append,prepend,offsetSet directives. 1. appendFile($src, $type = ‘text/javascript’, $attrs = array()) Parameters: $src=we will provide the source file which we want to append. $type=’text/javascript’ $attrs = array(); e.g ->appendFile( $this->baseUrl(‘js/lib/jquery/jquery-1.4.2.min.js’) ) 2.  offsetSetFile($index, [...]

Oct
31
2012

Zend JSON Helper

JSON stands for Java script Object Notation.JSON is used for storing and exchanging text information .It is much like XML.It is “self-describing” and easy to understand. In Zendframework when we create views that  returns the JSON , it’s important to also set the appropriate response header. The JSON view helper does exactly that. In addition, by default, it disables layouts (if currently enabled), as layouts generally aren’t used with JSON responses. The JSON helper sets the following header: Content-Type: application/json Most AJAX libraries [...]

Oct
25
2012

Zf Writing Custom Helpers

The class name must, at the very minimum, end with the helper name itself, using MixedCaps. E.g., if you were writing a helper called “Testhelper”, the class name would minimally need to be “Testhelper”. We should give the class name a prefix, and it is recommended that you use ‘View_Helper’ as part of that prefix: “My_View_Helper_Testhelper”. (Now you will need to pass in the prefix, with or without the trailing underscore, to addHelperPath() or setHelperPath()). [...]

Oct
19
2012

ZF Transfer Control

One of the powerful components of Zend Framework is the Zend_File_Transfer component which is useful while uploading and downloading files from a user’s computer to a Web server. This component is more flexible than handling uploads; it can also be used to transfer files using protocols such as FTP. It comes with built-in validators for files plus functionality to change files with filters. Protocol adapters allow Zend_File_Transfer to expose the same API for transport protocols [...]

Oct
18
2012

Zend Ajax Setup

In ZendFramework we can implement  AJAX, so now we will see how to put those pieces together. To make it more understanable , we will go through a simple example of how to add very basic AJAX to the Zend Framework  project. Step1. First we need to set up Ajax context switching in the main controller. Add the following init() function to the index controller found in controllers/IndexController.php public function init() { $ajaxContext = $this->_helper->getHelper(‘AjaxContext’); [...]

Oct
17
2012

Advantages of using Zend Framework

Zend Framework is an open-source software framework for PHP5. It has a flexible architecture that lets you build interactive web applications and web services effortlessly. One of its strengths is the highly modular Model-View-Controller design, which makes the code more reusable and easier to maintain and lets you focus on the big picture. Loosely coupled: The Zend Framework can be used as a component library. This means that you can choose to use only one [...]

Oct
16
2012

InstanceOf Operator

Instanceof  is used to determine: Whether a variable is an instantiated object of certain class. Whether a variable is an instantiated object of a class that inherits from a parent class. Whether a variable is an instantiated object of a class that implements an interface. Although instanceof is usually used with a literal class name, it can also be used with another object or a string variable. The instanceof operator was introduced in PHP 5. [...]

Oct
15
2012

ZF JSON Helper

JSON stands for Javascript Object Notation.JSON is systax which is used to store and exchange text information much like XML. JSON is smaller than XML, and faster and easier to parse. JSON responses are rapidly becoming the response of choice when dealing with AJAX requests that expect dataset responses; JSON can be immediately parsed on the client-side, leading to quick execution. Usage Usage is simple: either call it as a method of the helper broker, [...]

Oct
15
2012

PHP 5 Benchmarking Class

This class can be used to measure the time a PHP script takes to execute. It can start measuring the time in milliseconds that passes since any given point of a PHP script. The class can also suspend and resume the time measuring any time later in the script. It can return a formatted string with the list of periods of time that were measured. Example: The example below demonstrates an Object Oriented Approach to [...]

Oct
12
2012

Get Content of Ckeditor and Fckeditor Using Javascript

Sometimes we have to get data of ckeditor or fckeditor in  javascript . so next we are going to read about how to get data of ckeditor and fckeditor in javascript. Getting content of both editor is based on  creating object of editor. CKEDITOR: To get content of ckeditor we will create object of ckeditor and then we will provide id of textarea that is replaced by ckeditor. Syntax: CKEDITOR.instances.textarea_id.getData();getData(); Where CKEDITOR.instances   :  gives all [...]

Oct
11
2012

ZF HeadMeta Helper

In ZendFramework,we have HeadMeta helper with the help of which in HTML <meta> element which is used to provide meta information about your HTML document   — typically keywords, document character set, caching pragmas, etc. Meta tags may be either of the ‘http-equiv’ or ‘name’ types, must contain a ‘content’ attribute, and can also have either of the ‘lang’ or ‘scheme’ modifier attributes. The HeadMeta helper supports the following methods for setting and adding meta tags: [...]

Oct
10
2012

MySql Security

While writing about the MYSQL security issues there are some important points which should be considered and how they affect the security of your MySQL server and related applications Security issues:  There are some general factors that affect security of Mysql. These include choosing good passwords, not granting unnecessary privileges to users, application security should be there by preventing SQL injections, data corruption, and others. MySql issues while  post installation:  After installing MySQL, there are [...]

Oct
9
2012

Buffered versus Unbuffered Queries

Buffered Query : Buffered query will retrieve the query results  and  results are immediately transferred from the MySQL Server to PHP in is then kept in the memory of the PHP process. This allows additional operations like counting the number of rows, and moving (seeking) the current result pointer. It also allows issuing further queries on the same connection while working on the result set. Queries are using the buffered mode by default. The downside [...]

Oct
8
2012

ZF HeadStyle Helper

In ZendFramework we have HeadStyle Helper with the help of which in HTML <style> we can include css stylesheets inline in the HTML <head> element. The HeadStyle helper supports the following methods for setting and adding stylesheet declarations: 1. appendStyle($content, $attributes = array()) With the help of this method we can append the css style sheet in our script. 2. offsetSetStyle($index, $content, $attributes = array()) With the help of this method we can add our [...]

Oct
8
2012

EAV database design

Entity- Attribute- Value (EAV) database refers to a database design where a significant proportion of the data is modeled as EAV. However, in a database described as “EAV-based”, some tables in the system are relational tables Consider a supermarket database that must manage thousands of products and brands, many of which have a transitory existence. Here product names should not be hard-coded as names of columns in tables. Instead, one stores product descriptions in a [...]

Oct
8
2012

PHP Magic Methods

PHP provides a number of ‘magic’ methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met. We can not declare any user-defined functions with __ sign, and we can not use the magic methods name in any user-defined functions. Magic methods  have no concrete implementation and must be given a [...]

Oct
4
2012

ZF Menu Helper

In Zend framework, there is menu_helper for making menus links on your website. By default menus will be displayed in the UL and LI html tags.There are some methods which we will used for making menus. Methods in Menu_helper: {get|set}UlClass():  this method is used to gets/sets the CSS class used in renderMenu(). {get|set}ActiveClass():  gets/sets the CSS class for the active elements when we will render. {get|set}OnlyActiveBranch(): gets/sets a flag specifying whether only the active branch [...]

Oct
3
2012

MySql data types

MYSQL supports a number of data types in several categories: numeric types, date and time types, and string (character and byte) types. Defining the fields in a table is important for optimization of database you should only use the type and size of field don’t define a field as 10 characters wide if you know you’re only going to use 2 characters. These types of fields (or columns) are also referred to as data types, [...]

Oct
1
2012

ZF Translate Helper

As we know there are numerous websites in different languages so to translate the content of website we can use Zend_Translate .And to integrate the Zend_translate in our view we will use Translate View Helper. In all following examples we are using the simple Array Translation Adapter. Of course you can also use any instance of Zend_Translate and also any subclasses of Zend_Translate_Adapter. There are several ways to initiate the Translate View Helper: 1.Registered with [...]

Sep
28
2012

MySql Encryption Functions

The encryption functions used in MYSQL is just used to increase security of our database. As a security measure you can encrypt sensitive data in your database. When a hacker obtains access to your database, the hacker will find the encrypted data. You want your web application to enter new encrypted data into the database and you want to grant users of your web app access to the sensitive data without exposing the decryption key [...]