전체 글
-
mysql 프로시저 활용하기Sql 2023. 9. 7. 08:16
데이터를 (),(),(); 형태로 만들었고, insert하기 위한 프로시저를 실행시켰다 프로시저를 활용하는 이유 : insert / update 는 실행 중 일때 데이터의 안정성을 위해 해당 작업이 끝날 때 까지 다른 작업을 시작하지 않는다. 그렇기 때문에 실제로 운영하는 서버에서는 insert,update를 수행하는 시간을 매우짧게 가져가야한다. 여기서는 배열 형태의 데이터를 임시테이블에 저장해뒀다가 insert 시키기 위해 프로시저를 활용했다. CREATE DEFINER=`host` PROCEDURE `DataInsert`( IN `input_string` TEXT, IN `standardDate` INT ) LANGUAGE SQL NOT DETERMINISTIC CONTAINS SQL SQL SEC..
-
Class .. Staticphp 2023. 9. 6. 16:13
1. Static 으로 선언할 경우. Class 내부에서 Static으로 선언된 변수 / 메서드의 경우. 객체에 소속되는 것이 아니라 클래스에 고정되어 있다. -> Static이 선언된 요소는 클래스를 가져오기만 해도 메모리에 고정적으로 할당된다. 따라서, 인스턴스를 통해 객체를 생성하지 않아도 이용이 가능하다. 클래스를 불러오는 프로그램이 실행되면 자동으로 메모리에 static이 적재되고, 프로그램이 종료될 때 해제된다. ** 결국 Static은 사용자가 객체를 인스턴스하기 전 부터 올라가 있기 때문에, Static 요소 내부에서는 인스턴스 변수를 활용할 수 없다. ** 일반적인 요소의 경우, 객체를 생성하면 메모리의 Heap 영역에 올라간다. Heap 영역에 올라간 요소들은 Garbage Collec..
-
Classphp 2023. 9. 6. 09:07
php에서 클래스(객체)를 생성하고 선언하는 방법을 알아보자 class Account{ public int $number; public string $type; public float $balance; public function __construct($number, $type, $balance) { $this->number = $number; $this->type = $type; $this->balance = $balance; } public function deposit(float $amount): float { } public function withdraw(float $amount): float { } } 1. 객체 인스턴스 $account = new Account; $account2 = nes ..
-
지정인수php 2023. 9. 6. 08:30
PHP 8 에서 인수 앞에 매개변수 이름을 넣을 수 있다 만일 지정인수가 없다면 function( 3 , 5, 0 , 19 ); 와 같이 매개변수에 값을 넣지 않는 부분에도 0 을 꼭 넣어줘야한다 하지만 지정인수를 설정하면 순서에 상관없이 매개변수를 이용할 수 있다 public function calulate($cost , $quantity, $discount = 0 , $tax = 0){ } 위와같이 함수가 선언되었다면, calulate(5 , 10 , tax : 3); 또는 calulate(quantity : 7 , cost : 4 , tax : 10 ) 원하는 방법대로 함수를 호출할 수 있다
-
중복확인 쿼리문Sql 2023. 9. 4. 14:34
데이터베이스에 데이터를 넣은 후, 중복된 값이 존재하는지 확인하는 쿼리문이 있다 SELECT * FROM price GROUP BY ID, DATE HAVING COUNT(1) > 1 ORDER BY 1 DESC LIMIT 100; -> ID를 기준으로 100 번째 까지, id 와 date열을 그룹으로 묶어서 count(1) > 1 즉 하나 이상의 행이 있는 요소들을 select 하는 것이다. 따라서 해당 쿼리문의 결과로 아무런 데이터가 나오지 않는다면, 중복되는 값이 하나도 없다는 뜻이다
-
전역 / 정적 / 옵셔널 변수php 2023. 9. 4. 08:42
1. 전역변수 global $cost; 전역 범위에서, 변수에 저장된 값에 접근하거나 업데이트 할 수 있다 다른 프로젝트에서 봐야할 경우 위와 같이 선언한다. 2. 정적변수 static $value = 10; 일반적으로 함수 내에서 선언된 변수는 함수가 끝나면 삭제된다. 정적변수로 선언할 경우, 함수가 끝나도 변수를 삭제하지 않고 기억한다. 다만, 함수 내에서 선언되었기 때문에, 함수 내부의 코드에서만 사용할 수 있다. 3. 옵셔널 매개변수 php에서는 JAVA와 달리 오버로딩이 불가능하다. 그래서 함수에 매개변수가 선언되어 있다면, 함수를 호출할 때 항상 동일한 수의 매개변수가 필요하다. 하지만 옵셔널 매개변수를 활용하면, 해당 변수로 지정된 매개변수 없이 함수가 호출 된 경우 default 값을 가진..
-
워드프레스 페이지 추가php 2023. 9. 1. 12:11
서버에 올라가있는 프로젝트를 다운받고 숏코드를 활용해서 워드프레스 페이지를 추가해보자 1. 서버에 접속해서 관리자 권한으로 원하는 파일을 압축하자 ssh 서버명 sudo -s cd data/htdoc 위의 명령어로 프로젝트 파일이 있는 장소로 이동 후 tar cvf fileName.tar fileName tar을 이용해서 원하는 프로젝트를 압축한다. 2. filezilla를 활용해서 압축 된 파일을 로컬로 가져온다. 이 때, 서버의 host 계정이 필요하다 ip는 .ssh의 config 를 참조하자 3. 코드 변경 후 upload 될 수 있게 sftp.json을 수정해준다 4. FMS 에서 컨설팅 관리 -> 컨설팅을 등록 -> 설문 등록 DB에 페이지에서 나타내고싶은 데이터를 저장한다. 5. 워드프레스 ..