FTP, PHP, & SQL 인트로

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

2020년 9월 15일

스마트/하이브리드 앱 개발

복습 Entry no.2

FTP:

FTP - The File Transfer Protocol is a standard network protocol used for the transfer of computer files between a client and server on a computer network.

The difference between HTTP and FTP:

HTTP (Hypertext TP)

FTP (File TP)

used to access different websites on the internet

used to transfer files from one host to the another

establishes data connection only

establishes data as well as control connection

some facts about FTP:

  • 일반인은 잘 쓰지 않음. 왜냐하면 불편해서. 엔지니어들만 씀. This is typically used by companies when they share files that they need to protect with utmost privacy to another company; for ex, the sender-company gives the receiver-company an ID & Password that the receiver-company needs to plug in in order to access the sender-company's files.

There's a Windows 용 FTP Client 프로그램. 제일 많이 쓰는 얘는 알드라이브 임. (Note, 알드라이브 is the client for FTP. IE/Chrome is Web Server's client.)

PHP:

PHP로 코드 쓰면 파일명은 ~~.html 아님 ~~.php 여야 한다.

PHP는 Compiler 프로그램이 아니다. 보통 Compiler 면:

How compile programs work: the source code gets compiled into binary code for machines to understand. Typically program companies would give out the compiled binary code to their consumers who bought their program.

PHP is an interpreted language. An interpreted language is a type of programming language for which most of its implementations execute instructions directly and freely, without previously compiling a program into machine-language instructions.

The Client server, which is not the actual computer but browsers like IE/Chrome, uses HTTP protocol to request to the Web Server (Apache, in this case). The request ex: on browser 주소, 192.168.19.11/~st01 then hit enter. Then, if the user had added the PHP module (called a "parser" - parsing is 실행하기 전 단계) to Apache, then Apache will do the and know that the stuff inside the ("꺽새" as our 선생님 called it) is not html source code but PHP code. So then Apache will just RUN the php bit, instead of processing it like how it would with HTML.

PHP is a 100% server-side language. Side fact: game companies are trying to make everything 100% server-side so that the consumers' individual computers won't need a good video card for the games, since the server will run all of their individual games and just make it show up basically on their computer.

Since PHP was made for work (업무용), keyboard input을 인식을 못함. 그래서 게임 같은건 못만듬.

PHP doesn't even use real memory. It doesn't even have the concept of pointers. 변수 (variable) 타입도 자기가 알아서 바꿈.

변수: 값을 저장하기 위한 메모리 "그릇". It's a memory 번지수 in most programming languages except php. In the olden days, we used to type 16-digit memory addresses instead of the variables. lol.

$a = 1; -- > in here, $ is a 연산자 aka operator.

*요즘엔 변수 이름을 길게 쓰는게 추세임. 변수 이름 조건: 1) 대소문자 구분됨. 2) don't start with a number. 3) always must be in English. Never korean. 4) don't use special characters (특수문자).

Backslash () 역슬러시 --> is called an escape code. 탈출코드

회사에서 일하면:

변수명 --> 꼭 원칙에 따라 만들어야 함.

PHP는 $a = 1; 하고 $a = "AA"; 해도 됨. 다른 language에서는 안됨. "1" + 2 하면 3 으로 잘 알아서 함.

Playing around with PHP:

$bo= TRUE;

int=(integer)int= (integer)bo; --> find out what it turns out in php

str=(string)str= (string)bo; --> find out what it turns out to be in php

(integer)는 연산자 임.

computer language: 1이 마스킹 되어있는거임. TRUE. On the other hand, NULL은 거짓으로 봄. FALSE.

  • if you try to print the value of TRUE on a browser, it will come out as 1.

  • if you cast TRUE into an integer, it's 1.

  • if you cast TRUE into a string, it's "1".

  • if you try to print the value of FALSE on a browser, nothing will come out.

  • if you cast FALSE into an integer, it's 0.

  • if you cast FALSE into a string, it's either empty or null (not sure because you just can't see anything on the browser).

NULL은 값이 없단 뜻. 변수자체도 없단 얘기임.

PHP에선 $A=""도 NULL임.

single quotes '' 안에는 \n \r \t 이런 얘들이 안먹힘. so if you can, always try to use double quotes""

*브라우저에는 \n \r \t 이런 얘들 다 안나옴!

위에 있는 소스 코드들 다 실행해 보세요.

PHP prints out TRUE as 1. and it prints out strings without the quotations.

PHP form:

  • properties: method, action

    method: post or get. for post, 입력된 내용이 packet 안에 들어가서 전송이 됨. 많은양의 data를 전송 할수 있고 외부노출이 get 보다 덜 됨. 아예 없는건 아니고. for get, it's only used when post can't be used. lol

    action: basically where you want to send the info to. which page you want to send it to. ex: "0-3.php"

  • inside forms, there are inputs. various kinds like text, submit, reset. so it can be an input section or a button. they are all made through an input tag. an input should always have a name. so that you can retrieve the input value at the action website through $_POST[~~].

SQL:

  • Easy for 일반인 to learn.

(side note) in cmd prompt: >dir --> tells you what's inside the directory that you're in currently

To run SQL using Oracle:

sqlplus st01/1234@oracle (st01 is id and 1234 is password)

While running SQL, if you want to run an sql file, you just do SQL> @[filename] and press enter.

If you want to edit your database (which is an sql file), you just edit the data file you want and run it again.

***Btw, I use DB Browser to edit my sqlite files.

Excel has a limit on how much data it can hold. So companies use RDBSM (ex: Oracle, MySQL, SQLite, etc.)

Relational Database Management System.

The table columns used to be called fields, but now called columns. And entries are rows.

Queries:

 SELECT - data를 검색해서 봄. 

(DML)

 INSERT - table에 행을 더할때

 UPDATE

 DELETE

(DDL)

 CRERATE

 ALTER - table의 구조를 수정

 DROP

(DCL)

 GRANT

 REVOKE

SELECT [col, col, ... | *] --> * if you want all the columns of the table)

ex: 2 FROM table; *an SQL statement only ends when there's a semi-colon.

DESC table; --> table 구조를 검색한다. you also get each field's 유형 (type), like VARCHAR2 (which is text), DATE, NUMBER, and more. Column of type text is left-aligned. column of type number is right-aligned. (interesting lol)

SELECT * FROM tab; --> regurgitates back to you ALL the tables you have, i.e. in your schema.

SELECT * FROM student; --> the whole student table shows up

Reserved words for SQL: SELECT, EXTRACT, DESC, FROM, etc.... not exactly the same as queries.

0개의 댓글