난 듀얼모니터를 사용한게 한 4년쯤 되나보다 했는데 오늘 그전 글을 보다보니
2002년부터 사용을 했었네요. 그전엔 듀얼지원되는 그래픽카드를 하나 더 꽂아서 사용했던 기억이..
2004년부터는 저가형 그래픽카드에서도 dvi포트와 d-sub포트를 지원해서
17인치 평면crt 두개를 사용했던 기억이..
습관이 되다보니 아무래도 한 개의 모니터로는 작업능률이 제대로 나오지가 않네요.
예전 회사에서는 17인치 lcd 2개, 혹은 19인치 lcd 2개 쓰다가 지금은 22인치 와이드 1개, 19인치 일반 하나
쓰고 있네요. 적응안됨. ㅋ
컴퓨터와 부품가격은 나날이 떨어져가고..
2년 3개월전에 구입한 집컴퓨터 구입가격이면 현재 최고사양의 컴을 구매할 수 있는 때이니…
그나마 보드를 asus것을 쓰고 그래픽카드는 조금 무리를 해서 구입했더니 지금도 왠만한 게임 돌리는데는
문제가 없다.
내년쯤 좋은 사양으로 한대 구입하고 현재 컴은 아들과 와이프용으로… ^^
CentOS 5.1(32bit)에서 4G 메모리 지원하기
네이버, 구글에서 검색한 내용 조합한 것입니다.
현재 저희 서버에 적용하여 4G 인식후 사용중입니다.
예전에 centOS 4X 버전에서는 4G를 인식했습니다. 그래서 그전 회사에는 4G사용중 것을
확인했는데 이번에 새로 설치한 서버(centOS 5)에서는 3G밖에 인식을 못하더군요.
– 5버전으로 오면서 바뀌었답니다.
그래도 혹시나 해서 검색해봤더니 CPU가 PAE를 지원하면 4G인식이 가능하다였습니다.
1. /proc 디렉터리에서 cpuinfo 파일에서 해당 cpu가 PAE를 지원해야 한다.
cat /proc/cpuinfo |grep pae 명령실행후 pae 라는 라인이 보이면 지원하는 cpu
2. 커널 버전 확인(나중에 참고용)
# uname -r
2.6.18-53.1.21.el5
3. kernel-PAE 정보확인후 설치
yum info kernel-PAE
Available Packages
Name : kernel-PAE
Summary: The Linux kernel compiled for PAE capable machines.
Description:
This package includes a version of the Linux kernel with support for up to
64GB of high memory. It requires a CPU with Physical Address Extensions (PAE).
The non-PAE kernel can only address up to 4GB of memory.
Install the kernel-PAE package if your machine has more than 4GB of memory.
# yum install kernel-PAE
4. 2번 항목에서 확인한 커널버전 소스로 이동
cd /usr/src/kernels/2.6.18-53.1.21.el5
vi .config
항목중에서 CONFIG_HIGHMEM 이 있는지 찾아보고 없다면 아래 라인 입력
CONFIG_HIGHMEM4G=y
5. grub.conf 설정
cat /etc/grub.conf
커널버전뒤에 PAE가 붙은 커널로 부팅되도록 순서가 되어있는지 확인
default 순서는 0부터 시작해서 아래 설정은 두번째 2.6.18-53.1.21.el5PAE를 실행하는 것입니다.
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-53.1.21.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=LABEL=/
initrd /initrd-2.6.18-53.1.21.el5.img
title CentOS (2.6.18-53.1.21.el5PAE)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.1.21.el5PAE ro root=LABEL=/
initrd /initrd-2.6.18-53.1.21.el5PAE.img
title CentOS (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/
initrd /initrd-2.6.18-8.el5.img
6. 리부팅후 확인
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 4147056k total, 148424k used, 3998632k free, 8508k buffers
[MYSQL]트리거를 이용한 날짜 자동 업데이트
많은 분들이 아시겠지만 모르시는 분들을 위해 팁에 올립니다.
초보가 아닌 분은 뒤로 버튼을 눌러주시면 되겠습니다 ^^;
mysql 5.x 대부터 많은 변화가 있었는데요 이 중 Trigger에 대해 올릴까 합니다.
Trigger란 특정 테이블에 입력, 수정, 삭제가 이루어 졌을 경우 특정 명령을 실행하는 기능인데요,
이 트리거를 이용하여 테이블에 데이타를 수정했을 경우 수정한 날짜를 자동으로 기록하는 예제를 실행해 보도록 하겠습니다.
트리거를 이용하지 않고도 DEFAULT CURRENT_TIMESTAMP UPDATE ON CURRENT_TIMESTAMP 를 사용하면 해결되겠으나,
이미 입력날짜를 DEFAULT CURRENT_TIMESTAMP로 했을 경우 두 칼럼의 날짜를 자동으로 입력이 불가능할때 사용하시면 되겠습니다.
[mysql]트리거를 이용한 날짜 자동 업데이트
준비사항 : mysql 5.0 이상
*/
— 트리거용 테스트 테이블을 만듭니다
DROP TABLE TriggerTest;
CREATE TABLE TriggerTest (
pk INTEGER AUTO_INCREMENT PRIMARY KEY,
col01 VARCHAR(12) NOT NULL,
regDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, — 입력시
자동으로 날짜를 기입하기 위해 timestamp 타입과 기본 입력값으로 current_timestamp를 사용했습니다
modifyDate TIMESTAMP NOT NULL DEFAULT ‘0000-00-00 00:00:00’
)
— 트리거를 만듭니다.
— 기본 트리거 문법은 CREATE TRIGGER [트리거이름] [BEFORE|AFTER] [INSERT|UPDATE|DELETE] ON [테이블이름] FOR EACH ROW [실행문] 입니다
—
CREATE TRIGGER TRG_TriggerTest_UPDATE
BEFORE UPDATE ON TriggerTest
FOR EACH ROW
BEGIN
SET NEW.modifyDate = CURRENT_TIMESTAMP;
END;
— 테스트용 데이타를 입력합니다.
INSERT INTO TriggerTest SET col01 = ‘123’;
INSERT INTO TriggerTest SET col01 = ‘456’;
SELECT * FROM TriggerTest;
— 대략 아래와 같이 실행되었으리라 예상합니다.
pk col01 regDate modifyDate
——————————————————————————————————————
1 123 “2008-03-20 오전 11:33:44” ‘0000-00-00 00:00:00’
2 456 “2008-03-20 오전 11:33:44” ‘0000-00-00 00:00:00’
——————————————————————————————————————
–이제 PK가 2인 COL01 의 칼럼을 수정하겠습니다.
UPDATE TriggerTest SET col01 = ‘012’ where pk = 2;
— 결과를 보도록 하죠.
SELECT * FROM TriggerTest;
아래와 같이 수정한 칼럼의 수정일이 저장되었습니다.
pk col01 regDate modifyDate
——————————————————————————————————————
1 123 “2008-03-20 오전 11:33:44” ‘0000-00-00 00:00:00’
2 012 “2008-03-20 오전 11:33:44” “2008-03-20 오전 11:36:34”
——————————————————————————————————————
이 트리거를 좀더 활용하면 특정 테이블에 데이타가 들어오면 자동으로 다른 테이블에 입력, 수정, 삭제도 가능합니다.
짜집기한 MYSQL 클래스
20여개의 mysql 관련 클래스중에서 필요한 것만 모아서 짜집기한 클래스…
일반적인 mysql 클래스에 리스트와 페이징까지 한번에 처리하는 함수와 xml로 결과를 출력하는
함수 추가.
클래스내용 >>
[code]
//DB클래스
class dbH {
// PRIVATE 변수
private $CONN; // DB 커넥트
private $ERR_QUERY; // 에러가 발생한 쿼리
private $ERR_MSG; // 에러 메세지
private $RESULT; // 쿼리 결과
private $REC_COUNT; // 레코드 합계
private $ROW; // 레코드 결과 FETCH
private $ROWNUM; // 현재 레코드 번호
// 클래스 초기화
function dbH() {
$DB_HOST = “localhost”;
$DB_USER = “new_chong”;
$DB_PW = “new3432”;
$DB_NAME = “new_chong”;
$this->CONN = mysql_connect($DB_HOST, $DB_USER, $DB_PW) or die(“데이터베이트 연결 실패! 환경설정을 확인해주세요.”);
mysql_select_db($DB_NAME, $this->CONN) or die(“데이터베이트 접근 실패! 환경설정을 확인해주세요.”);
}
function getMessage()
{
return $this->message;
}
//GET NUM ROWS
function getNumRows()
{
return mysql_num_rows($this->result);
}
//GET AFFECTED ROWS
function getAffectedRows()
{
return mysql_affected_rows($this->result);
}
// INSERT, UPDATE, DELETE 등의 쿼리문 실행. (결과 없음)
function Open($query) {
$this->ERR_MSG = “”;
if (!mysql_query($query)) {
$this->ERR_QUERY = $query;
$this->ERR_MSG = mysql_error();
return false;
}
}
// SELECT 쿼리문 실행. (결과 있음)
function Execute($query) {
$this->ERR_MSG = “”;
if (!$this->RESULT = mysql_query($query)) {
$this->ERR_QUERY = $query;
$this->ERR_MSG = mysql_error();
return false;
}
else {
$this->REC_COUNT = mysql_num_rows($this->RESULT);
$this->ROW = mysql_fetch_assoc($this->RESULT);
$this->ROWNUM = 0;
}
}
// RecordCount
function RecordCount() {
return $this->REC_COUNT;
}
//insert_ID
function InsertID() {
if($this->result=mysql_insert_id($this->CONN)){
return($this->result);
} else {
return $this->errorMessage(“Cannot retrieve auto_increment value: $this->CONN”);
}
}
// 레코드 처음
function MoveFirst() {
mysql_data_seek($this->RESULT, 0);
$this->ROW = mysql_fetch_assoc($this->RESULT);
}
// 레코드 마지막
function MoveLast() {
mysql_data_seek($this->RESULT, $this->REC_COUNT – 1);
$this->ROW = mysql_fetch_assoc($this->RESULT);
}
// 다음 레코드
function MoveNext() {
$this->ROWNUM = $this->ROWNUM + 1;
if ($this->ROWNUM < $this->REC_COUNT) {
mysql_data_seek($this->RESULT, $this->ROWNUM);
$this->ROW = mysql_fetch_assoc($this->RESULT);
return true;
}
else { return false; }
}
// 이전 레코드
function MovePrev() {
$this->ROWNUM = $this->ROWNUM – 1;
if ($this->ROWNUM >= 0) {
mysql_data_seek($this->RESULT, $this->ROWNUM);
$this->ROW = mysql_fetch_assoc($this->RESULT);
return true;
}
else { return false; }
}
// 필드값 가져오기
function Field($field_name) {
return $this->ROW[$field_name];
}
// 데이터베이스 접속 종료
function Close() {
mysql_close($this->CONN);
}
// 가장 최근 에러메세지 표시
function ShowError() {
if (strlen($this->ERR_MSG) > 0) {
$msg = “<big><b>오류 내역입니다</b></big><br>”;
$msg .= “<table width=’100%’ border=’0′ cellpadding=’4′ cellspacing=’1′ bgcolor=’#BCBCBC’>”;
$msg .= “<tr>”;
$msg .= “<td bgcolor=’#EFEFEF’><span style=’font-size : 9pt;’><b>실행된 쿼리문</b></span></td>”;
$msg .= “<td bgcolor=’#FFFFFF’><span style=’font-size : 9pt; color : #666666;’>”.$this->ERR_QUERY.”</span></td>”;
$msg .= “</tr>”;
$msg .= “<tr>”;
$msg .= “<td bgcolor=’#EFEFEF’><span style=’font-size : 9pt;’><b>에러 메세지</b></span></td>”;
$msg .= “<td bgcolor=’#FFFFFF’><span style=’font-size : 9pt; color : #666666;’>”.$this->ERR_MSG.”</span></td>”;
$msg .= “</tr>”;
$msg .= “</table>”;
$msg .= “<br><br>”;
$msg .= “<div align=’center’><input type=’button’ value='<< MOVE BACK’ onClick=’history.go(-1)’ style=’border : solid 1 #000000; background-color : #5D5D5D; color : #FFFFFF;’>”;
echo $msg;
}
}
/********************************************
DO QUERY METHOD:결과 아이디 받아옴
*******************************************/
function doQuery($query)
{
$this->query=$query;
$this->result=mysql_query($this->query,$this->CONN) or die(mysql_error() );
return $this->result;
}
/********************************************
DO LIST:리스트 출력
*******************************************/
function doList($recordPerPage,$currentPage)
{
if($this->i==0)
{
$firstRecord=$recordPerPage*($currentPage-1);
$this->query=$this->query.’ LIMIT ‘.$firstRecord.’,’.$recordPerPage;
$this->result=$this->doQuery($this->query);
}
if(!$row=mysql_fetch_array($this->result) )
{
$this->query=explode(‘LIMIT’,$this->query);
$this->query=$this->query[0];
$this->result=$this->doQuery($this->query);
$this->i=0;
return false;
}
//RETURN ROWS
$this->i++;
return $row;
}
/********************************************
GET PAGE INDEX:페이지 인텍스 HTML코드 반환
*******************************************/
function getPageIndex($recordPerPage,$currentPage)
{
//SET ARRAY REFER TO PARAMETERS:페이지 인덱스 생성을 위한 기본값 정렬
$pageIndex[totalRecord] = $this->getNumRows();
$pageIndex[recordPerPage] = $recordPerPage;
$pageIndex[pagePerBlock] = 10;
$pageIndex[currentPage] = $currentPage;
//CALCULATE PAGE IDNEX:
$pageIndex[totalPage]=ceil($pageIndex[totalRecord]/$pageIndex[recordPerPage]);
$pageIndex[currentBlock]=ceil($pageIndex[currentPage]/$pageIndex[pagePerBlock]);
$pageIndex[totalBlock]=ceil($pageIndex[totalPage]/$pageIndex[pagePerBlock]);
//FIRST PAGE/LAST PAGE
$pageIndex[firstPage]=($pageIndex[currentBlock]*$pageIndex[pagePerBlock]) – ($pageIndex[pagePerBlock]-1);
$pageIndex[lastPage]=($pageIndex[currentBlock]*$pageIndex[pagePerBlock]);
/****************************************
//DEFINE NEW QUERY_STRING
페이지 링크 정의를 위한 URL파싱
***************************************/
parse_str($_SERVER[QUERY_STRING],$QUERY_STRING);
unset($QUERY_STRING[page]);
foreach($QUERY_STRING as $key=>$value)
{
if(!$temp){
$temp=”$key=$value”;
}else{
$temp.=”&$key=$value”;
}
}
$QUERY_STRING=$temp;
/****************************************
CREATE PAGE INDEX HTML CODE
HTML코드 생성
***************************************/
##PREVIOUS BLOCK
if($pageIndex[currentPage] > $pageIndex[pagePerBlock])
{
$pageIndex[htmlCode]='<a href=”.$_SERVER[PHP_SELF].’?’.$QUERY_STRING.’&page=’.( ($pageIndex[currentBlock]-2)*$pageIndex[pagePerBlock]+1).” target=’_self’ onfocus=’blur();’ > 이전 </a>’;
}
##PAGE INDEX
for($i=$pageIndex[firstPage]; $i<=$pageIndex[lastPage]; $i++)
{
if($i<=$pageIndex[totalPage])
{
if($i==$pageIndex[currentPage])
{
$pageIndex[htmlCode].=’ <b>’.$i.'</b>’;
}else{
$pageIndex[htmlCode].='<a href=”.$_SERVER[PHP_SELF].’?’.$QUERY_STRING.’&page=’.$i.” target=’_self’ onfocus=’blur();’ > ‘.$i.’ </a>’;
}
}
}
##NEXT BLOCK
if($pageIndex[currentBlock] <= ($pageIndex[totalBlock]-1) )
{
$pageIndex[htmlCode].='<a href=”.$_SERVER[PHP_SELF].’?’.$QUERY_STRING.’&page=’.($pageIndex[currentBlock]*$pageIndex[pagePerBlock]+1).” target=’_self’ onfocus=’blur();’ > 다음 </a>’;
}
##RETURN PAGE INDEX ARRAY
return $pageIndex;
}//END METHOD
/********************************************
DO SELECT
*******************************************/
function doSelect($query)
{
$this->query=$query;
$this->result = $this->doQuery($this->query);
return mysql_fetch_array($this->result);
}
/********************************************
DO INSERT METHOD
배열을 참조,데이타베이스에 입력
*******************************************/
function doInsert($table,$array)
{
##GET TABLE STRUCTURE
$query=”SHOW COLUMNS FROM $table”;
$result=mysql_query($query,$this->CONN);
while($row=mysql_fetch_array($result) )
{
$columns[$i]=$row[Field];
$values[$i]=”‘”.$array[$columns[$i]].”‘”;
$i++;
}
$columns=implode(“,”,$columns);
$values=implode(“,”,$values);
##SEND QUERY STATEMENT;
$query=”INSERT INTO $table ($columns) VALUES ($values)”;
$result=mysql_query($query,$this->CONN);
if(!$result)
{
die(mysql_error() );
return false;
}else{
return true;
}
}
/********************************************
DO UPDATE METHOD
업데이트
*******************************************/
function doUpdate($table,$array,$key_name,$key_value)
{
##GET TABLE STRUCTURE
$query=”SHOW COLUMNS FROM $table”;
$result=mysql_query($query,$this->CONN);
$i=0;
while($row=mysql_fetch_array($result) )
{
if(isset($array[$row[Field]]) )
{
$set[$i]=$row[Field].”='”.$array[$row[Field]].”‘”;
$i++;
}
}
$set=implode(“,”,$set);
##EXECUTE QUERY STATEMENT
$query=”UPDATE $table SET $set WHERE $key_name=’$key_value'”;
$this->doQuery($query);
return true;
}
/********************************************
테이블 리스트 반환
*******************************************/
function GetTableList(){
if($this->result=mysql_list_tables($DB_NAME,$this->CONN)){
$i=0;
while($i < mysql_num_rows($this->result)){
$tb_names[$i]=mysql_tablename($this->result,$i);
$i++;
}
return($tb_names);
}else
return $this->errorMessage(“Unable to find any tables in database: $DB_NAME”);
}
/********************************************
필드명 반환
*******************************************/
function GetFieldList($tbl_name){
if($this->result=mysql_list_fields($DB_NAME,$tbl_name,$this->CONN)){
$i=0;
while($i < mysql_num_fields($this->result)){
$fd_names[$i]=mysql_field_name($this->result,$i);
$i++;
}
return($fd_names);
}else
return $this->errorMessage(“Unable to find any field list in table: $tbl_name”);
}
/******************************************** 글쓴이 kimsee 날 짜 08-02-28 16:58 조 회 2284 도움이 될 지 모르겠지만.. 이런 내용은 없는것 같아서.. 올려봅니다.. connect->query( $input ); $this->results[ $name ] = ( $output ) ? $output : false; } function __get ( $name ) { $output = ( $this->results[ $name ] ) ? $this->result[ $name ]->fetch_assoc() : false; return ( $output ) ? $output : false; } … } $db = new exam(); $db->test = ‘SELECT * FROM test’; echo ‘
returns XML-formatted record rows from query results.
$this->data holds the XML only, and the function returns the XML header + the data
example:
header(“Content-type: text/xml”);
echo $sql->XML_Output(“SELECT * FROM yourTable”);
********************************************/
function XML_DataOutput($query, $tags = array(‘dataset’,’record’)) {
if($this->result=mysql_query($query,$this->CONN)) {
$this->fields=mysql_num_fields($this->result);
$xmlheader='<?xml version=”1.0″ ?>’.””;
$this->data.='<‘.$tags[0].’>’.””;
while($this->rows = mysql_fetch_array($this->result)) {
$this->data.= “‘”>\\t\\t”.'<‘.$tag.’>’. preg_replace(“/([\\r])/”, ”, strip_tags($this->rows[$i])). ‘</’.$tag.’>’.””;
}
$this->data.= “
[함수] __set(), __get() 활용..
‘;
‘; ?> DB 클래스(mysqli)의 경우입니다.. 위처럼 그냥 쿼리만 지정하면.. 값을 부를때는 결과가 나오죠.. 단순히 변수처럼 쿼리를 입력하면 결과를 불러오게 됩니다.. 코드도 간결해 지고.. 편하죠..
print_r($db->test);
print_r($db->test);
print_r($db->test);
print_r($db->test);
echo ‘