SQL rollback/commit, PHP arrays/foreach

Hyun Seo (Lucy) Lee 이현서·2020년 9월 24일
0
post-thumbnail

Rollback | Commit

  • in 2 separate command prompts (ie 2 separate sessions), if one of them deletes a table, when the other also tries to modify the table somehow, it (the second one) is put on hold.

  • The first one needs to either rollback, un-deleting the data, or commit and actually delete the data table.

  • the process of editing data all the way up to the rollback / commit is called a "transaction"

  • ingeneral, when you do an insert/update/delete query, it's a rule to commit or rollback ASAP.

  • It's meaningful to note that Oracle and DB2 allows entry-specific locks, while others like SQL server only have table locks.

PHP - arrays

  • you can put text as array keys, not just numbers. usually in other coding langauges, you can only use numbers as keys for arrays.

  • some useful functions:

    • count(); counts the number of elements in an array
    • print_r(); --> to print an array
  • foreach ---> easy to use, but only good for certain cases. For instance, you have to loop through every single element in the array with a foreach loop, while for-loops allow for sectional loops.

    foreach usage: foreach ($array as $value) {} or foreach ($array as $key => $value) {}

  • if you go to php.net, you'll be able to find a function that sorts an array

  • in PHP, each element in an array is basically a variable.

0개의 댓글