Week 11 - PHP & MySQL Part 2 Flashcards
What is the best practice when creating tables in MySQL and PHP?
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.
What’s an important keyword so that everything isn’t selected?
The conditional keyword WHERE will make sure that only certain things are selected
AUTO_INCREMENT
A new unique number is given each time a new record is generated.
(car_id)
When and why is NULL used?
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.
UPDATE
A keyword used to change records in a database. It also needs the keyword SET to set the new values to that record.
mysqli_affected_rows()
Used to tell the user which rows have been affected by a query.
mysqli_free_result()
Used to free the memory from the result variable.
mysqli_free_result()
Used to free the memory from the result variable.
mysqli_fetch_assoc()
It will take the records from the database and put them into an associative array.
mysqli_fetch_row()
It will take the records from the database and put them into an indexed array.
What’s the difference between an associative and indexed array?
Indexed arrays will have values assigned to index keys starting from zero.
Associative arrays will have values assigned to strings, like a hash.
What’s the difference between an mysqli_fetch_assoc() and mysqli_fetch_row()?
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.
ORDER BY
A keyword used for sorting the records in a database.
DESC can be used to set the order to descending.