svnno****@sourc*****
svnno****@sourc*****
2010年 4月 22日 (木) 01:33:26 JST
Revision: 196 http://sourceforge.jp/projects/sangokushi/svn/view?view=rev&revision=196 Author: okotaneko Date: 2010-04-22 01:33:26 +0900 (Thu, 22 Apr 2010) Log Message: ----------- bindParam追å ãªã© Modified Paths: -------------- trunk/server_php/dbutil.php trunk/server_php/main.php trunk/server_php/sysparam.inc Modified: trunk/server_php/dbutil.php =================================================================== --- trunk/server_php/dbutil.php 2010-04-20 23:14:52 UTC (rev 195) +++ trunk/server_php/dbutil.php 2010-04-21 16:33:26 UTC (rev 196) @@ -272,6 +272,23 @@ /** * selectæãçºè¡ãã * + * @param array $s PDOStatementãªãã¸ã§ã¯ã + * @param array $param ãã¤ã³ãå¤æ°ã®é ç®ã¨å¤ã®ããã·ã¥é å + * @return void + * @access private + */ + private function setBindParam(&$s, &$param) { + + if (! empty($param)) { + foreach ($param as $key => $value) { + $s->bindParam("$param[$key]", "$value"); + } + } + } + + /** + * selectæãçºè¡ãã + * * @param string $sql å®è¡ããSQLæå¿ ããã¤ã³ãå¤æ°ã使ç¨ããã㨠* @param array $param ãã¤ã³ãå¤æ°ã®é ç®ã¨å¤ã®ããã·ã¥é å * @return array string çµæã»ãã @@ -280,11 +297,15 @@ */ public function query_select(&$sql, &$param) { - $S = $this->Db->prepare($sql); - $S->execute($param); + $s = $this->Db->prepare($sql); + $this->setBindParam($s, $param); - return $S->fetchAll(); + if (! $s->execute($param)) { + throw new Exception('0030001', SYSTEM_ERROR); + } + return $s->fetchAll(); + } /** @@ -297,13 +318,14 @@ */ public function query_update(&$sql, &$param) { - $S = $this->Db->prepare($sql); - if (! $S->execute($param)) { - $arr = $S->errorInfo(); - print_r($arr); + $s = $this->Db->prepare($sql); + $this->setBindParam($s, $param); + + if (! $s->execute($param)) { + throw new Exception('0030002', SYSTEM_ERROR); } - return $S->rowCount(); + return $s->rowCount(); } Modified: trunk/server_php/main.php =================================================================== --- trunk/server_php/main.php 2010-04-20 23:14:52 UTC (rev 195) +++ trunk/server_php/main.php 2010-04-21 16:33:26 UTC (rev 196) @@ -77,7 +77,7 @@ // R}hG[(ÎR}hªÈ¢) default: -// throw new Exception('0000001', SYSTEM_ERROR); + throw new Exception('0000001', SYSTEM_ERROR); } Modified: trunk/server_php/sysparam.inc =================================================================== --- trunk/server_php/sysparam.inc 2010-04-20 23:14:52 UTC (rev 195) +++ trunk/server_php/sysparam.inc 2010-04-21 16:33:26 UTC (rev 196) @@ -24,7 +24,7 @@ * * @var string OuVXeªÆ©Égp·éG[R[h */ -define('SYSTEMQERROR', 99); +define('SYSTEM_ERROR', 99); /** * s¾ÈG[R[h