[PHP] SimpleSql 라이브러리를 사용한 손쉬운 쿼리사용

[PHP] SimpleSql 라이브러리를 사용한 손쉬운 쿼리사용

/*** 기타 생략 ***/

public function update($table, array $data, $where = array()) {

/*** 기타 생략 ***/

// handle data portion

$dataSql = array();

foreach ($data as $key => $val) {

if (strpos($key, ":") === 0) {

$dataSql[] = substr($key, 1) . " = " . $key;

} else {

$dataSql[] = $key . " = :" . $key;

}

}

$sql .= implode(",

", $dataSql);

/* 쿼리 구문 추가 */

$sql .= " WHERE ";

// handle where clause

if (!empty($where)) {

/*** 기타 생략 ***/

}

/*** 기타 생략 ***/

?>

from http://wickedmagica.tistory.com/25 by ccl(A) rewrite - 2021-10-27 22:27:00