Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building a Web Application with PHP and MariaDB: A Reference Guide

You're reading from   Building a Web Application with PHP and MariaDB: A Reference Guide Build fast, secure, and interactive web applications using this comprehensive guide

Arrow left icon
Product type Paperback
Published in Jun 2014
Publisher
ISBN-13 9781783981625
Length 200 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sai S Sriparasa Sai S Sriparasa
Author Profile Icon Sai S Sriparasa
Sai S Sriparasa
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. CRUD Operations, Sorting, Filtering, and Joins 2. Advanced Programming with MariaDB FREE CHAPTER 3. Advanced Programming with PHP 4. Setting Up Student Portal 5. Working with Files and Directories 6. Authentication and Access Control 7. Caching 8. REST API 9. Security 10. Performance Optimization Index

Working with stored routines

Stored routines are similar to stored procedures; both of them contain a block of SQL statements. There are a few differences such as a stored routine cannot return a result set and that a stored routine has to return a value and therefore, not preferred over stored procedures. Stored routines are invoked using the SELECT statement and can interchangeably be called as functions. The SHA1 function that we are using is a system-built stored routine to generate hashes for strings. Let's build a simple stored routine that would return the full name of the student when a username is passed in as a parameter, as shown in the following screenshot:

Working with stored routines

Note

We will be using the fn_functionName convention for our stored routines.

We begin by using the CREATE FUNCTION DDL command, appended by the name of the function, to create the function. This function takes the student's username as a parameter and returns the full name of the student, if the student exists. In...

You have been reading a chapter from
Building a Web Application with PHP and MariaDB: A Reference Guide
Published in: Jun 2014
Publisher:
ISBN-13: 9781783981625
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime