본문 바로가기
반응형

IT/PHP14

CONVERT_TZ : mysql 타임존 변경 CONVERT_TZ('2008-05-15 12:00:00','+00:00','+10:00'); In MySQL the CONVERT_TZ() returns a resulting value after converting a datetime value from a time zone specified as the second argument to the time zone specified as the third argument. This function returns NULL when the arguments are invalid Name Description dt A datetime. from_tz A time zone which will be converted to to_tz. to_tz A time zo.. 2022. 6. 16.
json_decode 함수 null 반환 json data 의 일부를 변수로 받은 후 json_decode 함수를 사용했는데 null 이 반환되었다이유는 변수 앞뒤에 필요없는 /n 이 포함되었기 때문이었다해결 방법은 trim 함수를 사용하는 것이다trim 은 문자열 앞뒤에 있는 다음 값을 제거한다" " (ASCII 32 (0x20)), an ordinary space."\t" (ASCII 9 (0x09)), a tab."\n" (ASCII 10 (0x0A)), a new line (line feed)."\r" (ASCII 13 (0x0D)), a carriage return."\0" (ASCII 0 (0x00)), the NUL-byte."\x0B" (ASCII 11 (0x0B)), a vertical tab. $name = trim($name.. 2017. 7. 25.
Mysql 의 Password() 함수로 만든 hash 를 bcrpyt 로 변경해주는 Wordpress plugin 옛날 홈페이지를 워드프레스로 이전하는 도중에, 사용자 암호 역시 이전하기 위해 만들었다이 플러그인은 https://roots.io/plugins/bcrypt-password/ 를 수정해서 만들었다. Github 에서 원본 소스를 fork 한 git 주소이다https://github.com/jjjnlove/wp-password-bcrypt/commits/master 옛 홈페이지에서 사용자 비번을 mysql 의 password() 를 사용하여 저장하고 있었다mysql 개발자 사이트에 가보면 다음과 같은 내용이 있다PASSWORD() is used by the authentication system in MySQL Server; you shouldnot use it in your own applications.. 2017. 5. 30.
[PHP] PDO API 자세한 정보는 http://php.net/manual/kr/book.pdo.phpThe PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-spec.. 2016. 10. 22.
PHP MySqli 사용 예제 define("DBUSER", "root"); define("DBPASS", "root"); define("DBNAME", "tlc_db"); define("DBHOST", "localhost"); $conn = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);if ($conn->connect_error){ trigger_error("Database connection failed :" . $connection->connect_error, E_USER_ERROR);}$sql = "select m_id, m_name, m_sex, m_age, m_phone, m_address from member_table;";$ret = $conn->query($sql);if (false.. 2016. 10. 19.
PHP Trait Trait 는 PHP 5.4 부터 추가된 기능이다Trait는 어떤 특정 기능의 코드를 재사용 가능하게 해 준다.Trait 로 상속없이 특정 기능을 추가할 수 있게 된다. Trait 는 클래스에 추가할 Method 들의 집합이다 trait teach_something { public function say($words) { echo $words; }}class Teacher { use teach_something;}class Manager { use teach_something;}$teacher = new Teacher;$teacher->say("study"); 2016. 10. 7.
PHP list 문 list ($family_name, $middle_name, $last_name) = ["Lee", "Middle", "James"]; $MyFamily = [["Lee", "Milddle", "James"],["Kim", "2nd", "Mary"],]; foreach ($MyFamily as list($family_name, $middle_name, $last_name)){echo $family_name.$middle_name.$last_name;} 2016. 10. 3.
Language construct echo, print, include, isset, require 등의 함수는 Language construct 이다그렇다면 Language construct 라는 것은 무엇인가? 네이버에서 검색에 나온 전자용어사전의 정의는 다음과 같다언어구성요소 : 프로그램 언어를 기술하기 위해 필요한 구문상의 구성 요소. 예를 들면 식별자, 명령문, 모듈 등 Wikipedia 의 정의는 다음과 같다A language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language.The ter.. 2016. 9. 25.
Maria DB Query 사용법 및 기타 주의 사항 SQL 명령어는 대소문자를 구분하지 않으며, 문장의 마지막에는 세미콜론( ; )으로 마쳐야 한다.SQL 에서 NULL 은 값이 없음을 나타낸다 ● Create database member_db; // member_db 라는 db 생성● Show databases; // db 목록 출력● use db_member; // db_member 선택● create table tb_member(member_id int, member_name varchar(64)); // tb_member 생성● show tables; // table 목록 출력● describe tb_member; // tb_member 테이블 구조 출력● insert into tb_member(member_id, member_name) value.. 2016. 9. 12.
PHP namespace 네임스페이스를 사용하면 다른 개발자들의 코드에 같은 이름의 클래스나 인터페이스, 함수, 상수가 있어도 충돌하지 않고 같이 사용할 수 있다.PHP 5.3 부터 클래스, 인터페이스, 네임스페이스를 import 할 수 있고, 별칭을 지정할 수도 있다.PHP 5.6 부터는 함수와 상수도 임포트하거나 별칭을 지정할 수 있다네임스페이스는 PHP 파일에서 제일 위의 2016. 8. 21.
반응형