Week 11 - PHP & MySQL Part 2 Flashcards

1
Q

What is the best practice when creating tables in MySQL and PHP?

A

You should use an if statement to check if a table already exists and if not then create one otherwise keep querying the same one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s an important keyword so that everything isn’t selected?

A

The conditional keyword WHERE will make sure that only certain things are selected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

AUTO_INCREMENT

A

A new unique number is given each time a new record is generated.

(car_id)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When and why is NULL used?

A

NULL is used for fields which require no values such as AUTO_INCREMENT.

This will be done in a query if needed but otherwise defined in the CREATE TABLE query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

UPDATE

A

A keyword used to change records in a database. It also needs the keyword SET to set the new values to that record.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

mysqli_affected_rows()

A

Used to tell the user which rows have been affected by a query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

mysqli_free_result()

A

Used to free the memory from the result variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

mysqli_free_result()

A

Used to free the memory from the result variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

mysqli_fetch_assoc()

A

It will take the records from the database and put them into an associative array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

mysqli_fetch_row()

A

It will take the records from the database and put them into an indexed array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What’s the difference between an associative and indexed array?

A

Indexed arrays will have values assigned to index keys starting from zero.

Associative arrays will have values assigned to strings, like a hash.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What’s the difference between an mysqli_fetch_assoc() and mysqli_fetch_row()?

A

Where mysqli_fetch_assoc() will retrieve the records and put them into an associative array, mysqli_fetch_row() will put these records into an indexed array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ORDER BY

A

A keyword used for sorting the records in a database.

DESC can be used to set the order to descending.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly