표기법이 달라 같은 엔티티 참조가 어려울때, 한쪽의 표기법을 변경하는 방법
자바나 자바스크립트 변수명 또는 XML의 node, attribute name이 camel 을 쓰고,
DB Column이 underscore(_) 를 쓰죠.
( db 컬럼과 xml 의 node명을 상호 참조할경우 아래와 같이 변환해서 쓰면 좋습니다.
xml을 파싱해서 db에 넣는다던지, db를 조회해서 xml을 만든다던지..
)
<?php
/**
* Translates a camel case string into a string with underscores (e.g. firstName -> first_name)
* @param string $str String in camel case format
* @return string $str Translated into underscore format
*/
function from_camel_case($str) {
$str[0] = strtolower($str[0]);
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
return preg_replace_callback('/([A-Z])/', $func, $str);
}
/**
* Translates a string with underscores into camel case (e.g. first_name -> firstName)
* @param string $str String in underscore format
* @param bool $capitalise_first_char If true, capitalise the first char in $str
* @return string $str translated into camel caps
*/
function to_camel_case($str, $capitalise_first_char = false) {
if($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
$func = create_function('$c', 'return strtoupper($c[1]);');
return preg_replace_callback('/_([a-z])/', $func, $str);
}
/**
* Translates a camel case string into a string with underscores (e.g. firstName -> first_name)
* @param string $str String in camel case format
* @return string $str Translated into underscore format
*/
function from_camel_case($str) {
$str[0] = strtolower($str[0]);
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
return preg_replace_callback('/([A-Z])/', $func, $str);
}
/**
* Translates a string with underscores into camel case (e.g. first_name -> firstName)
* @param string $str String in underscore format
* @param bool $capitalise_first_char If true, capitalise the first char in $str
* @return string $str translated into camel caps
*/
function to_camel_case($str, $capitalise_first_char = false) {
if($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
$func = create_function('$c', 'return strtoupper($c[1]);');
return preg_replace_callback('/_([a-z])/', $func, $str);
}
$test1 = "MODIFY_DATE";
$test2 = "modifyDate";
$result1 = to_camel_case(strtolower($test1));
$result2 = strtoupper(from_camel_case($test2));
echo "$test1 => $result1 <br>";
echo "$test2 => $result2 <br>";
echo "$test2 => $result2 <br>";
?>
output:
MODIFY_DATE => modifyDate
modifyDate => MODIFY_DATE
modifyDate => MODIFY_DATE
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 401 | ||
| 8029 | 9년 전 | 326 | ||
| 8028 | 9년 전 | 285 | ||
| 8027 | 9년 전 | 295 | ||
| 8026 | 9년 전 | 367 | ||
| 8025 | 9년 전 | 405 | ||
| 8024 | 9년 전 | 377 | ||
| 8023 | 9년 전 | 415 | ||
| 8022 | 9년 전 | 332 | ||
| 8021 | 9년 전 | 350 | ||
| 8020 | 9년 전 | 343 | ||
| 8019 | 9년 전 | 361 | ||
| 8018 | 9년 전 | 465 | ||
| 8017 | 9년 전 | 551 | ||
| 8016 | 9년 전 | 364 | ||
| 8015 | 9년 전 | 410 | ||
| 8014 | 9년 전 | 341 | ||
| 8013 | 9년 전 | 259 | ||
| 8012 | 9년 전 | 263 | ||
| 8011 | 9년 전 | 464 | ||
| 8010 | 9년 전 | 320 | ||
| 8009 | 9년 전 | 331 | ||
| 8008 | 9년 전 | 301 | ||
| 8007 | 9년 전 | 452 | ||
| 8006 | 9년 전 | 489 | ||
| 8005 |
|
9년 전 | 985 | |
| 8004 | 9년 전 | 373 | ||
| 8003 | 9년 전 | 445 | ||
| 8002 | 9년 전 | 340 | ||
| 8001 |
|
9년 전 | 683 | |
| 8000 | 9년 전 | 442 | ||
| 7999 | 9년 전 | 398 | ||
| 7998 | 9년 전 | 453 | ||
| 7997 | 9년 전 | 325 | ||
| 7996 | 9년 전 | 559 | ||
| 7995 | 9년 전 | 494 | ||
| 7994 | 9년 전 | 375 | ||
| 7993 | 9년 전 | 438 | ||
| 7992 | 9년 전 | 534 | ||
| 7991 | 9년 전 | 280 | ||
| 7990 | 9년 전 | 309 | ||
| 7989 | 9년 전 | 323 | ||
| 7988 | 9년 전 | 751 | ||
| 7987 | 9년 전 | 453 | ||
| 7986 | 9년 전 | 452 | ||
| 7985 | 9년 전 | 532 | ||
| 7984 | 9년 전 | 446 | ||
| 7983 | 9년 전 | 691 | ||
| 7982 | 9년 전 | 550 | ||
| 7981 | 9년 전 | 504 | ||
| 7980 | 9년 전 | 525 | ||
| 7979 | 9년 전 | 515 | ||
| 7978 | 9년 전 | 482 | ||
| 7977 | 9년 전 | 420 | ||
| 7976 | 9년 전 | 881 | ||
| 7975 | 9년 전 | 391 | ||
| 7974 | 9년 전 | 427 | ||
| 7973 | 9년 전 | 624 | ||
| 7972 | 9년 전 | 409 | ||
| 7971 | 9년 전 | 478 | ||
| 7970 | 9년 전 | 324 | ||
| 7969 | 9년 전 | 563 | ||
| 7968 | 9년 전 | 410 | ||
| 7967 | 9년 전 | 393 | ||
| 7966 | 9년 전 | 405 | ||
| 7965 |
|
9년 전 | 1039 | |
| 7964 | 9년 전 | 424 | ||
| 7963 | 9년 전 | 435 | ||
| 7962 | 9년 전 | 427 | ||
| 7961 |
전갈자리남자
|
9년 전 | 523 | |
| 7960 | 9년 전 | 988 | ||
| 7959 | 9년 전 | 568 | ||
| 7958 | 9년 전 | 429 | ||
| 7957 | 9년 전 | 381 | ||
| 7956 | 9년 전 | 380 | ||
| 7955 | 9년 전 | 482 | ||
| 7954 | 9년 전 | 414 | ||
| 7953 | 9년 전 | 460 | ||
| 7952 | 9년 전 | 383 | ||
| 7951 | 9년 전 | 519 | ||
| 7950 | 9년 전 | 415 | ||
| 7949 | 9년 전 | 408 | ||
| 7948 | 9년 전 | 346 | ||
| 7947 | 9년 전 | 956 | ||
| 7946 | 9년 전 | 468 | ||
| 7945 | 9년 전 | 421 | ||
| 7944 | 9년 전 | 469 | ||
| 7943 | 9년 전 | 406 | ||
| 7942 | 9년 전 | 427 | ||
| 7941 | 9년 전 | 416 | ||
| 7940 | 9년 전 | 918 | ||
| 7939 | 9년 전 | 394 | ||
| 7938 | 9년 전 | 423 | ||
| 7937 | 9년 전 | 308 | ||
| 7936 | 9년 전 | 902 | ||
| 7935 | 9년 전 | 484 | ||
| 7934 | 9년 전 | 458 | ||
| 7933 | 9년 전 | 573 | ||
| 7932 | 9년 전 | 525 | ||
| 7931 | 9년 전 | 582 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기