2018/10 6

CodeIgniter에서 쿼리 결과에 처리 주의할 점 ; COUNT () 등 함수 사용 등

CodeIgniter에서 DB의 쿼리 결과를 받아서 처리하는데, unbuffered_row() 또는 row() 함수를 이용하게 되는데, 주의할 점은 기본적으로 레코드가 stdClass Object로 변환되어 받게 된다는 점이다. 문제는 다음과 같이 쿼리를 작성하였을 경우, "COUNT" 에 대한 변수명을 처리하기가 애매해 진다. $sql = "SELECT COUNT(1) FROM member WHERE user_name LIKE '%{$name}%';"; foreach()를 통하여 반환된 레코드 클래스에 접근한다면 문제가 발생하지 않지만, key value 쌍으로 반환되기 때문에 해당 key를 찾아서 작업을 별도로 해줘야 하기 때문에 번거로운 작업이 필요하게 된다.다음은 Pagination을 위하여 전체..

프로그래밍/PHP 2018.10.31

[javascript] 숫자에 천단위 마다 콤마(,) 넣기

특정 숫자에 천단위 마다 콤마를 넣기 위하여 다음 정규표현식을 이용하면 간단하게 해결된다. 아래와 같이 하면, 정수형에 대해서는 아무런 문제가 발생하지 않으나, 소수점이 있는 실수형의 경우에는 오류가 발생하게 된다. function toCommaString( number ) { var regexp = /\B(?=(\d{3})+(?!\d))/g; return number.toString().replace( regexp, ',' ); } 그래서 아래와 같이, 정수형과 실수형을 구분하여 함수를 만들어서 사용한다. function toCommaStringF( number ) { var number_string = number.toString(); var number_parts = number_string.spl..

Install apache24 + PHP7 + CodeIgniter3 for Windows

Windows 개발 환경에서 apache24 + PHP7 + CodeIgniter3 를 설치하여 연동하는 방법을 기술합니다.CodeIgniter3 를 호출할 때, index.php가 없어도 되도록 rewrite 모듈 설정도 포함합니다. Install apache24apache24 download in https://www.apachelounge.com/download/ : Apache 2.4.35 Win64Extract to "C:\Dev\Apache24" Edit httpd.conf : "C:\Dev\Apache24\conf\httpd.conf"Set ServerRoot Define SRVROOT "c:/Dev/Apache24"Set ServerName ServerName devwb.mydomain.c..

프로그래밍/PHP 2018.10.17

PHP debug in Visual Studio code

xDebug.dll download v2.6.1 for PHP 7.2 (Thread safe x64)자신이 설치한 PHP 버전에 맞는 DLL을 다운로드 해야함phpinfo의 결과 정보를 확인하거나, 잘 모를 경우에는 phpinfo() 결과를 복사하여 https://xdebug.org/wizard.php 에 붙여넣어 다운로드할 파일을 자동을 확인할 수 있음 Download and copy : C:/Dev/php-7.2.10/extphp.ini 파일의 수정 ; 다음 내용을 추가함 [XDebug] ; xdebug*.dll 파일 경로 zend_extension=C:/Dev/php-7.2.10/ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll xdebug.remote_host=127.0.0..

프로그래밍/PHP 2018.10.11

nginx + PHP installation (for windows 10)

nginx 다운로드 및 압축 풀기 ; v1.15.5php 다운로드 및 압축 풀기 ; v7.2.10php.ini 설정 파일 생성하기 ; 압축을 해제한 C:\Dev\php-7.2.10 폴더의 "php.ini-development" 파일을 "php.ini" 파일로 복사php-cgi 실행 C:\Dev\php-7.2.10>start php-cgi.exe -b 127.0.0.1:9000 nginx.conf 파일 수정 ; php 연동을 위한 설정 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.ph..

프로그래밍/PHP 2018.10.10
728x90