표기법이 달라 같은 엔티티 참조가 어려울때, 한쪽의 표기법을 변경하는 방법
자바나 자바스크립트 변수명 또는 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 161 | ||
| 8229 | 9년 전 | 131 | ||
| 8228 |
커네드커네드
|
9년 전 | 180 | |
| 8227 | 9년 전 | 224 | ||
| 8226 | 9년 전 | 238 | ||
| 8225 | 9년 전 | 219 | ||
| 8224 | 9년 전 | 227 | ||
| 8223 | 9년 전 | 203 | ||
| 8222 |
|
9년 전 | 263 | |
| 8221 | 9년 전 | 169 | ||
| 8220 | 9년 전 | 203 | ||
| 8219 | 9년 전 | 174 | ||
| 8218 | 9년 전 | 221 | ||
| 8217 |
star3840
|
9년 전 | 189 | |
| 8216 | 9년 전 | 253 | ||
| 8215 | 9년 전 | 200 | ||
| 8214 | 9년 전 | 316 | ||
| 8213 | 9년 전 | 265 | ||
| 8212 | 9년 전 | 175 | ||
| 8211 | 9년 전 | 351 | ||
| 8210 | 9년 전 | 347 | ||
| 8209 | 9년 전 | 427 | ||
| 8208 | 9년 전 | 312 | ||
| 8207 | 9년 전 | 324 | ||
| 8206 |
|
9년 전 | 275 | |
| 8205 | 9년 전 | 248 | ||
| 8204 | 9년 전 | 232 | ||
| 8203 | 9년 전 | 302 | ||
| 8202 | 9년 전 | 219 | ||
| 8201 | 9년 전 | 260 | ||
| 8200 | 9년 전 | 272 | ||
| 8199 | 9년 전 | 292 | ||
| 8198 | 9년 전 | 257 | ||
| 8197 | 9년 전 | 240 | ||
| 8196 | 9년 전 | 657 | ||
| 8195 | 9년 전 | 251 | ||
| 8194 | 9년 전 | 362 | ||
| 8193 | 9년 전 | 272 | ||
| 8192 | 9년 전 | 287 | ||
| 8191 | 9년 전 | 237 | ||
| 8190 | 9년 전 | 223 | ||
| 8189 | 9년 전 | 288 | ||
| 8188 | 9년 전 | 220 | ||
| 8187 | 9년 전 | 226 | ||
| 8186 | 9년 전 | 227 | ||
| 8185 | 9년 전 | 394 | ||
| 8184 | 9년 전 | 184 | ||
| 8183 | 9년 전 | 397 | ||
| 8182 | 9년 전 | 261 | ||
| 8181 | 9년 전 | 222 | ||
| 8180 | 9년 전 | 790 | ||
| 8179 | 9년 전 | 558 | ||
| 8178 | 9년 전 | 426 | ||
| 8177 |
kiplayer
|
9년 전 | 419 | |
| 8176 | 9년 전 | 456 | ||
| 8175 | 9년 전 | 345 | ||
| 8174 | 9년 전 | 333 | ||
| 8173 | 9년 전 | 425 | ||
| 8172 | 9년 전 | 304 | ||
| 8171 | 9년 전 | 267 | ||
| 8170 | 9년 전 | 380 | ||
| 8169 |
커네드커네드
|
9년 전 | 336 | |
| 8168 | 9년 전 | 416 | ||
| 8167 | 9년 전 | 406 | ||
| 8166 | 9년 전 | 312 | ||
| 8165 | 9년 전 | 255 | ||
| 8164 | 9년 전 | 388 | ||
| 8163 | 9년 전 | 386 | ||
| 8162 | 9년 전 | 377 | ||
| 8161 | 9년 전 | 394 | ||
| 8160 |
|
9년 전 | 606 | |
| 8159 | 9년 전 | 548 | ||
| 8158 | 9년 전 | 344 | ||
| 8157 | 9년 전 | 458 | ||
| 8156 | 9년 전 | 344 | ||
| 8155 | 9년 전 | 348 | ||
| 8154 |
00년생용띠
|
9년 전 | 677 | |
| 8153 | 9년 전 | 313 | ||
| 8152 |
|
9년 전 | 495 | |
| 8151 | 9년 전 | 492 | ||
| 8150 | 9년 전 | 598 | ||
| 8149 |
Jangfolk
|
9년 전 | 460 | |
| 8148 | 9년 전 | 278 | ||
| 8147 | 9년 전 | 461 | ||
| 8146 | 9년 전 | 543 | ||
| 8145 | 9년 전 | 497 | ||
| 8144 | 9년 전 | 463 | ||
| 8143 | 9년 전 | 298 | ||
| 8142 | 9년 전 | 508 | ||
| 8141 | 9년 전 | 457 | ||
| 8140 | 9년 전 | 1021 | ||
| 8139 | 9년 전 | 371 | ||
| 8138 |
전갈자리남자
|
9년 전 | 470 | |
| 8137 | 9년 전 | 506 | ||
| 8136 | 9년 전 | 841 | ||
| 8135 |
|
9년 전 | 877 | |
| 8134 |
PlayPixel
|
9년 전 | 615 | |
| 8133 |
|
9년 전 | 522 | |
| 8132 | 9년 전 | 561 | ||
| 8131 | 9년 전 | 919 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기