표기법이 달라 같은 엔티티 참조가 어려울때, 한쪽의 표기법을 변경하는 방법
자바나 자바스크립트 변수명 또는 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년 전 | 172 | ||
| 8229 | 9년 전 | 154 | ||
| 8228 |
커네드커네드
|
9년 전 | 196 | |
| 8227 | 9년 전 | 235 | ||
| 8226 | 9년 전 | 254 | ||
| 8225 | 9년 전 | 233 | ||
| 8224 | 9년 전 | 244 | ||
| 8223 | 9년 전 | 219 | ||
| 8222 |
|
9년 전 | 283 | |
| 8221 | 9년 전 | 181 | ||
| 8220 | 9년 전 | 218 | ||
| 8219 | 9년 전 | 195 | ||
| 8218 | 9년 전 | 237 | ||
| 8217 |
star3840
|
9년 전 | 204 | |
| 8216 | 9년 전 | 269 | ||
| 8215 | 9년 전 | 216 | ||
| 8214 | 9년 전 | 328 | ||
| 8213 | 9년 전 | 284 | ||
| 8212 | 9년 전 | 196 | ||
| 8211 | 9년 전 | 365 | ||
| 8210 | 9년 전 | 365 | ||
| 8209 | 9년 전 | 439 | ||
| 8208 | 9년 전 | 330 | ||
| 8207 | 9년 전 | 340 | ||
| 8206 |
|
9년 전 | 284 | |
| 8205 | 9년 전 | 260 | ||
| 8204 | 9년 전 | 247 | ||
| 8203 | 9년 전 | 325 | ||
| 8202 | 9년 전 | 242 | ||
| 8201 | 9년 전 | 271 | ||
| 8200 | 9년 전 | 284 | ||
| 8199 | 9년 전 | 308 | ||
| 8198 | 9년 전 | 272 | ||
| 8197 | 9년 전 | 254 | ||
| 8196 | 9년 전 | 677 | ||
| 8195 | 9년 전 | 266 | ||
| 8194 | 9년 전 | 375 | ||
| 8193 | 9년 전 | 284 | ||
| 8192 | 9년 전 | 299 | ||
| 8191 | 9년 전 | 255 | ||
| 8190 | 9년 전 | 237 | ||
| 8189 | 9년 전 | 297 | ||
| 8188 | 9년 전 | 234 | ||
| 8187 | 9년 전 | 243 | ||
| 8186 | 9년 전 | 241 | ||
| 8185 | 9년 전 | 414 | ||
| 8184 | 9년 전 | 199 | ||
| 8183 | 9년 전 | 406 | ||
| 8182 | 9년 전 | 278 | ||
| 8181 | 9년 전 | 232 | ||
| 8180 | 9년 전 | 802 | ||
| 8179 | 9년 전 | 580 | ||
| 8178 | 9년 전 | 441 | ||
| 8177 |
kiplayer
|
9년 전 | 436 | |
| 8176 | 9년 전 | 469 | ||
| 8175 | 9년 전 | 356 | ||
| 8174 | 9년 전 | 349 | ||
| 8173 | 9년 전 | 435 | ||
| 8172 | 9년 전 | 314 | ||
| 8171 | 9년 전 | 275 | ||
| 8170 | 9년 전 | 399 | ||
| 8169 |
커네드커네드
|
9년 전 | 354 | |
| 8168 | 9년 전 | 434 | ||
| 8167 | 9년 전 | 424 | ||
| 8166 | 9년 전 | 320 | ||
| 8165 | 9년 전 | 265 | ||
| 8164 | 9년 전 | 399 | ||
| 8163 | 9년 전 | 405 | ||
| 8162 | 9년 전 | 389 | ||
| 8161 | 9년 전 | 406 | ||
| 8160 |
|
9년 전 | 624 | |
| 8159 | 9년 전 | 569 | ||
| 8158 | 9년 전 | 362 | ||
| 8157 | 9년 전 | 476 | ||
| 8156 | 9년 전 | 355 | ||
| 8155 | 9년 전 | 360 | ||
| 8154 |
00년생용띠
|
9년 전 | 695 | |
| 8153 | 9년 전 | 327 | ||
| 8152 |
|
9년 전 | 508 | |
| 8151 | 9년 전 | 505 | ||
| 8150 | 9년 전 | 619 | ||
| 8149 |
Jangfolk
|
9년 전 | 479 | |
| 8148 | 9년 전 | 289 | ||
| 8147 | 9년 전 | 474 | ||
| 8146 | 9년 전 | 556 | ||
| 8145 | 9년 전 | 513 | ||
| 8144 | 9년 전 | 481 | ||
| 8143 | 9년 전 | 312 | ||
| 8142 | 9년 전 | 522 | ||
| 8141 | 9년 전 | 466 | ||
| 8140 | 9년 전 | 1031 | ||
| 8139 | 9년 전 | 380 | ||
| 8138 |
전갈자리남자
|
9년 전 | 485 | |
| 8137 | 9년 전 | 521 | ||
| 8136 | 9년 전 | 849 | ||
| 8135 |
|
9년 전 | 890 | |
| 8134 |
PlayPixel
|
9년 전 | 630 | |
| 8133 |
|
9년 전 | 538 | |
| 8132 | 9년 전 | 579 | ||
| 8131 | 9년 전 | 934 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기