Lecture 4
Lecture 4
Information Technology
Web Technologies II
Data abstraction
looking at named collections of data
Control abstraction
looking at program control mechanisms
Web engineering community two main approaches
have emerged depending on whether the application
development is approached from an information or
a user perspective:
1- Information-centric design processes start
with activities related to the
back-end of an information system.
2- User-centric design processes start
from the analysis of the users’ activities.
Workflow design is thus the first step, and
the resulting workflow serves as an input
for navigation design where workflows
are transformed into sequences of
navigation steps.
Refinement
Refinement goes hand in hand with abstraction.
As a design process continues,
stepwise refinement of the abstractions is
employed to clarify the details of the
designs and its transformations to the models
closer to the implementation
environment. Refinement plays a crucial role in
Web application design as well.
Depending on the chosen approach, the navigation models
refine either data models or workflow models. Similarly,
presentation models are refinements of the navigation models.
The data, navigation, and presentation models are
mapped onto the architecture that describes the overall
organization of the Web application. Structural partitioning is a
common approach to structure a system for
follow-up refinements. The partitioning can be horizontal or
vertical.
Modularity
Modularity is a principle of software system design
that enables the software to be manageable. The
software is decomposed into a set of modules that
are integrated to satisfy the collected requirements.
Modularity contributes to better understandability of
the subproblems the software is supposed to solve,
to better integrability, and to easier introduction of
changes that do not affect the whole system; it also
reduces the impact of failures to specific
submodules.
PHP & MySQL
Functions
• Functions MUST be defined before then can be
called
• Function headers are of the format
function functionName($arg_1, $arg_2, …, $arg_n)
– Note that no return type is specified
• Unlike variables, function names are not case
sensitive (foo(…) == Foo(…) == FoO(…))
Functions example
<?php
// This is a function
function foo($arg_1, $arg_2)
{
$arg_2 = $arg_1 * $arg_2;
return $arg_2;
}
Parameter Values
Parameter Description
// Create connection
$conn = mysqli_connect($servername, $username,
$password, $dbname);
Create Table
$sql = "CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDAT
CURRENT_TIMESTAMP)";
if (mysqli_query($conn, $sql)) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . mysqli_error($conn)
}
Insert Data
$sql = "INSERT INTO MyGuests (firstname, lastname,
email)
VALUES ('John', 'Doe', '[email protected]')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" .
mysqli_error($conn);
}
Insert Multiple
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', '[email protected]');";
$sql .= "INSERT INTO MyGuests (firstname, lastname,
email)
VALUES ('Mary', 'Moe', '[email protected]');";
$sql .= "INSERT INTO MyGuests (firstname, lastname,
email)
VALUES ('Julie', 'Dooley', '[email protected]')";
if (mysqli_multi_query($conn, $sql)) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
Delete Data
// sql to delete a record
$sql = "DELETE FROM MyGuests WHERE id=3";