표기법이 달라 같은 엔티티 참조가 어려울때, 한쪽의 표기법을 변경하는 방법
자바나 자바스크립트 변수명 또는 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4730 |
제너레이션
|
13년 전 | 1003 | |
| 4729 | 13년 전 | 947 | ||
| 4728 | 13년 전 | 701 | ||
| 4727 | 13년 전 | 1246 | ||
| 4726 | 13년 전 | 852 | ||
| 4725 | 13년 전 | 1682 | ||
| 4724 | 13년 전 | 1021 | ||
| 4723 | 13년 전 | 2689 | ||
| 4722 | 13년 전 | 562 | ||
| 4721 |
ECEditor
|
13년 전 | 2233 | |
| 4720 | 13년 전 | 2616 | ||
| 4719 | 13년 전 | 4389 | ||
| 4718 | 13년 전 | 962 | ||
| 4717 | 13년 전 | 1174 | ||
| 4716 | 13년 전 | 1353 | ||
| 4715 |
한번잘해보자
|
13년 전 | 1169 | |
| 4714 | 13년 전 | 1177 | ||
| 4713 | 13년 전 | 2827 | ||
| 4712 | 13년 전 | 1250 | ||
| 4711 |
김준수사랑
|
13년 전 | 1014 | |
| 4710 |
한번잘해보자
|
13년 전 | 1147 | |
| 4709 | 13년 전 | 1142 | ||
| 4708 | 13년 전 | 820 | ||
| 4707 | 13년 전 | 1702 | ||
| 4706 |
프로프리랜서
|
13년 전 | 2091 | |
| 4705 |
프로프리랜서
|
13년 전 | 1380 | |
| 4704 | 13년 전 | 969 | ||
| 4703 |
프로프리랜서
|
13년 전 | 936 | |
| 4702 | 13년 전 | 836 | ||
| 4701 | 13년 전 | 1571 | ||
| 4700 | 13년 전 | 2599 | ||
| 4699 | 13년 전 | 1312 | ||
| 4698 |
|
13년 전 | 1601 | |
| 4697 |
|
13년 전 | 1118 | |
| 4696 |
|
13년 전 | 1136 | |
| 4695 |
|
13년 전 | 1347 | |
| 4694 |
|
13년 전 | 864 | |
| 4693 |
|
13년 전 | 855 | |
| 4692 |
|
13년 전 | 858 | |
| 4691 |
|
13년 전 | 1186 | |
| 4690 |
|
13년 전 | 1271 | |
| 4689 |
|
13년 전 | 1020 | |
| 4688 |
|
13년 전 | 780 | |
| 4687 |
|
13년 전 | 1055 | |
| 4686 |
|
13년 전 | 1009 | |
| 4685 |
|
13년 전 | 940 | |
| 4684 |
|
13년 전 | 1042 | |
| 4683 |
|
13년 전 | 933 | |
| 4682 |
|
13년 전 | 1243 | |
| 4681 |
|
13년 전 | 1020 | |
| 4680 |
|
13년 전 | 1143 | |
| 4679 |
|
13년 전 | 1654 | |
| 4678 |
|
13년 전 | 581 | |
| 4677 | 13년 전 | 2913 | ||
| 4676 |
복이219
|
13년 전 | 620 | |
| 4675 | 13년 전 | 816 | ||
| 4674 | 13년 전 | 614 | ||
| 4673 | 13년 전 | 992 | ||
| 4672 | 13년 전 | 934 | ||
| 4671 | 13년 전 | 1200 | ||
| 4670 | 13년 전 | 718 | ||
| 4669 | 13년 전 | 1778 | ||
| 4668 | 13년 전 | 1420 | ||
| 4667 |
너는나의봄이다
|
13년 전 | 1022 | |
| 4666 | 13년 전 | 6695 | ||
| 4665 | 13년 전 | 628 | ||
| 4664 | 13년 전 | 1003 | ||
| 4663 | 13년 전 | 843 | ||
| 4662 | 13년 전 | 976 | ||
| 4661 | 13년 전 | 1244 | ||
| 4660 | 13년 전 | 845 | ||
| 4659 | 13년 전 | 1105 | ||
| 4658 |
소나무닷컴
|
13년 전 | 689 | |
| 4657 | 13년 전 | 709 | ||
| 4656 |
|
13년 전 | 1243 | |
| 4655 | 13년 전 | 3101 | ||
| 4654 | 13년 전 | 677 | ||
| 4653 | 13년 전 | 2099 | ||
| 4652 | 13년 전 | 874 | ||
| 4651 | 13년 전 | 776 | ||
| 4650 | 13년 전 | 1669 | ||
| 4649 | 13년 전 | 1600 | ||
| 4648 | 13년 전 | 614 | ||
| 4647 | 13년 전 | 1508 | ||
| 4646 | 13년 전 | 1937 | ||
| 4645 | 13년 전 | 1336 | ||
| 4644 | 13년 전 | 610 | ||
| 4643 | 13년 전 | 2025 | ||
| 4642 | 13년 전 | 821 | ||
| 4641 |
|
13년 전 | 607 | |
| 4640 | 13년 전 | 567 | ||
| 4639 |
|
13년 전 | 1295 | |
| 4638 |
|
13년 전 | 1665 | |
| 4637 |
|
13년 전 | 1137 | |
| 4636 | 13년 전 | 633 | ||
| 4635 | 13년 전 | 762 | ||
| 4634 | 13년 전 | 1266 | ||
| 4633 | 13년 전 | 1245 | ||
| 4632 |
|
13년 전 | 543 | |
| 4631 | 13년 전 | 3342 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기