Databases Midterm

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is an update anomaly

When one or more instances of duplicated data is updated

In PHP can identifiers have the same name as a function?

Yes

How to bulk insert into SQL

INSERT INTO Table1 VALUES (1, 'FirstName', 'LastName'), (2, 'FirstName', 'LastName')

What is the definition of a relational database schema

Tables, columns and relationships that make up a relational database

How to test for equality in PHP between two variables

==

How to test for identity in PHP between two variables

===

how to encrypt a password

$enc_pass = password_hash("password", PASSWORD_DEFAULT);

how to read a file in php

$file = fopen($path, "r"); $contents = fread($file, filesize($path)); fclose($file);

how to write to a file in php

$file = fopen($path, "rw"); fwrite($file, "content"); fclose($file);

How to run sql query

$mysqli = new mysqli("localhost", "user", "password", "db1"); $result $mysqli->query($query); $row = $result->fetch_array(MYSQLI_ASSOC); $result->close(); $mysqli->close();

How to access a global variable

$var = 0; function test() { $GLOBALS["var"] = 1}

How do you create a new MySQL database

CREATE DATABASE [IF NOT EXISTS] dbname1;

How to create a table with an auto-increment primary key, a foreign key, and an indexed archer column

CREATE TABLE Example ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, FOREIGN KEY (ForKeyCol) REFERENCES ForeignTable (ID) ON DELETE CASCADE )

How to create a user on mysql

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

A ____________ join Represents the Cartesian product of two tables

CROSS

What are the three pillars of security

Confidentiality Integrity Availability

What MySQL privileges allow users to remove databases, tables, or views?

DROP

What is DDL

Data Definition Language

What is DML

Data Manipulation Language

In database connection string terminology, DSN stands for

Data source name

How to grant privileges to a user on mysql

GRANT ALL PRIVILEDGES ON db1.* TO 'user'@'localhost';

Are PHP functions case sensitive

No

Are global variables visible inside of functions through normal behavior

No, they must be accessed with the global function

You can use the generic _______ functions if you want to use a database that doesn't have a php library

ODBC

What does ODBC stand for

Open Database Connectivity

What does PDO stand for

PHP Data Object

In a database-backend PHP application, the ________ opens a db connection

PHP server

MySQL ______ can speed up query execution as well as protect against SQL injection attacks

Prepared Statements

How to revoke privileges from a user on mysql

REVOKE alter, create, drop ON db1.* FROM 'user'@'localhost'

Which of the following is a php statement that allows you to load a file into your PHP script?

Require

What is an inner join

Return all elements that can be matched both ways between the left and the right tables

What kind of PHP variable stores a single value

Scalar

What is the first step in querying a MySQL db from the web

Validate user input

What is the function name reserved for constructors

__construct($param)

What is the function name reserved for destructors

__construct($param)

Check if a key exists

array_key_exists("key", $array)

How to get the keys of a dict

array_keys($array)

How do you add an element to an array

array_push($array, "value")

How to find the key/index of a search

array_search("value", $array)

Which of the following is a php.ini directive that points to a header file

auto_prepend_file

How to clone an object

by default clone $object will create a shallow clone, implement __clone to achieve a deep copy

How to count the elements in an array

count($array)

A foreign key should have the same or comparable __________ as its related primary key

datatype

how to write a foreach

foreach($array as $value) { stuff($value);}

What is the function of PDO

defines a consistent interface for accessing databases in PHP

PHP string interpolation requires what kind of quotation mark?

double quotes

IN PHP-MySQL connectivity, what is the purpose fo the @ symbol

error suppressor?

What is the use of required_once and included_once

files won't be imported more than once

What files would have to be modified to add authentication to the homework

home_page processAddressUpdate processStatisticsUpdate

What are the differences between htmlspecialchars() function and the htmlentities()

htmlentities covers more characters than htmlspecialchars

How to encode html

htmlspecialchars($html)

How to test if an element is in an array

in_array("value", $array)

What is the role of 'foo' in the php statement function('foo');

its a parameter

PHP variables that are declared inside a function are known as

local

What is the basic PHP library for connection to MySQL

mysqli

A primary key can consist of ______ columns

one or more

how to call a parents version of a method

parent::func()

What is the default PHP class modifier

public

A PHP function that calls itself is known as a ________ function

recursive

What is the difference between include and require

require will throw an error if it doesn't exist

What is a left join

return all elements from the left table and those from the right table who can be matched to something on the left

What is a right join

return all elements from the right table and those from the left table who can be matched to something on the right

What is an alias for the chop() function

rtrim

What is the difference between single and double quotes in php

single quotes takes text 100% literally, while double quotes will interpolate things like \n

The three different PHP sorting functions are

sort - standard sort asort - sort an array, maintaining index association rsort - reverse sort

The php keyword return

stops the execution of a function

in the context of a class, what does the self keyword refer to

the class itself, use it to access static attributes and functions

in the context of a class, what does the $this keyword refer to

the current object itself

How to get GET params from php

the super global $_GET array (dict)

How to get GET params from php

the super global $_POST array (dict)

How to throw an exception in php

throw new Exception($message, $code);

how to raise an error in php

trigger_error($message, $level)

Which command do you use to specify which MySQL db to use

use dbname;

In PHP, the normal way that function parameters are called is known as pass by _________

value

What is the use of the __autoload function

you declare it and define the methodology for finding the file containing the class given the classname as param called when a classname is used and PHP can't locate its declaration


Kaugnay na mga set ng pag-aaral

NR 222 - Health and Wellness Study Guide

View Set

RN 402 ATI ARDS Practice Questions

View Set

Psychology Cognitive Development & Language

View Set

16th- Century Northern Renaissance

View Set