Book Image

Ext JS Data-driven Application Design

By : Kazuhiro Kotsutsumi
Book Image

Ext JS Data-driven Application Design

By: Kazuhiro Kotsutsumi

Overview of this book

Sencha Ext JS is an industry leader for business-standard web application development. Ext JS is a leading JavaScript framework that comes with a myriad of components, APIs, and extensive documentation that you can harness to build powerful and interactive applications. Using Ext JS, you can quickly develop rich desktop web applications that are compatible with all major browsers. This book will enable you to build databases using information from an existing database with Ext JS. It covers the MVC application architecture that enables development teams to work independently on one project. Additionally, the book teaches advanced charting capability, enabling developers to create state-of-the-art charts just once. These charts are compatible with major browsers without the need to rely on plugins. This hands-on, practical guide will take you through the mechanics of building an application. In this instance, we will use this application to manage existing data structures in the form of a database. You will begin by making SQL and tables in MySQL and will then move on to developing the project environment and introducing Sencha Cmd. You will learn to create a form to input data and monitor the state of the input, while seeing how Ext Direct will validate the form on the server side. Finally, you will have a working application that is ready for you to customize to suit your needs. You can also use it as a template for any future projects when you need a similar database.
Table of Contents (14 chapters)
Ext JS Data-driven Application Design
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating each operation and testing


Because we will use PHP in later stages, let's prepare each operation now. Here, we will insert some temporary data.

Remember to check that the acquisition and update operations are working properly.

User authentication

These are some SQL code you can use to develop your database.

You can look for a user by inputting an e-mail address and password. You can assume it was successful if the count is 1.

For increased password security, after having carried out MD5 encryption, you should store the password as a character string of 40 characters after being put through SHA1.

SELECT
    COUNT(id) as auth
FROM
    users
WHERE
    users.email = '[email protected]'
AND
    users.passwd = SHA1(MD5('password'))
AND
    users.status = 1;

Selecting the user list

This is used when you want to collect data for use in a grid. Make note of the fact that we are not performing the limit operation with PagingToolbar:

SELECT
    users.id,
    users.email,
    users.lastname,
    users.firstname
FROM
    users
WHERE
    users.status = 1;

Adding users

To add a user, put the current time in created and modified:

INSERT INTO users (
    email,
    passwd,
    lastname,
    firstname,
    modified,
    created
) VALUES (
    '[email protected]',
    SHA1(MD5('password')),
    'Kotsutsumi',
    'Kazuhiro',
    NOW(),
    NOW()
);

Updating the user information

Every time the modified file should be set to NOW() for it to be used as a time stamp. Other fields should be updated as needed.

UPDATE
    users
SET
    email='[email protected]',
    passwd=SHA1(MD5('password')),
    lastname='Kotsutsumi',
    firstname='Kazuhiro',
    modified=NOW()
WHERE
    id=1

Deleting users

Deletion from this system is not a hard purge where the user data is permanently deleted. Instead we will use a soft purge, where the user data is not displayed after deletion but remains in the system. Therefore, note that we will use UPDATE, not DELETE. In the following code, status=9 denotes that the user has been deleted but not displayed. (status=1 will denote that the user is active).

UPDATE
    users
SET
    status=9
WHERE
    id=1