| 14 | | public function replace($key, $name, $defaultValue){ |
| 15 | | return call_user_func(array($this, 'replace_' . $this->dbms), $key, $name, $defaultValue); |
| 16 | | } |
| 17 | | public function replace_mysql($key, $name, $defaultValue){ |
| 18 | | if($this->info->typeofIn($name)){ |
| 19 | | $this->bindKeys[] = $name; |
| 20 | | return ':' . $name; |
| 21 | | } |
| 22 | | if($this->info->typeofOut($name) || $this->info->typeofInOut($name)){ |
| 23 | | $this->bindKeys[] = $name; |
| 24 | | $this->outParams[] = $name; |
| 25 | | return '@' . $name; |
| 26 | | } |
| 27 | | throw new RuntimeException('unknown "' . $name . '" parameter'); |
| 28 | | } |
| 29 | | public function bind(PDOStatement $stmt, $value){ |
| 30 | | return call_user_func(array($this, 'bind_' . $this->dbms), $stmt, $value); |
| 31 | | } |
| 32 | | |
| 33 | | public function bind_mysql(PDOStatement $stmt, $value){ |
| 34 | | $param = $value[0]; |
| 35 | | foreach($this->bindKeys as $index => $key){ |
| 36 | | $prefix = ''; |
| 37 | | if($this->info->typeofIn($key)){ |
| 38 | | $stmt->bindParam(':' . $key, $param->$key); |
| 39 | | } |
| 40 | | } |
| 41 | | } |
| 42 | | |
| 46 | | |
| | 23 | public function replace($key, $name, $defaultValue){ |
| | 24 | $this->bindKeys[] = $name; |
| | 25 | if($this->info->typeofOut($name) || $this->info->typeofInOut($name)){ |
| | 26 | $this->outParams[] = $name; |
| | 27 | } |
| | 28 | return ':' . $name; |
| | 29 | } |
| | 30 | public function bind(PDOStatement $stmt, $value){ |
| | 31 | $param = $value[0]; |
| | 32 | foreach($this->bindKeys as $index => $key){ |
| | 33 | $bindKey = ':' . $key; |
| | 34 | if($this->info->typeofIn($key)){ |
| | 35 | $stmt->bindParam($bindKey, $param->$key); |
| | 36 | continue; |
| | 37 | } |
| | 38 | $paramValue = $param->$key; |
| | 39 | if(null === $paramValue){ |
| | 40 | $stmt->bindParam($bindKey, null, PDO::PARAM_NULL | PDO::PARAM_INPUT_OUTPUT); |
| | 41 | continue; |
| | 42 | } |
| | 43 | $gettype = gettype($paramValue); |
| | 44 | $paramType = -1; |
| | 45 | if(isset(self::$pdoTypes[$gettype])){ |
| | 46 | $paramType = self::$pdoTypes[$gettype] | PDO::PARAM_INPUT_OUTPUT; |
| | 47 | } else { |
| | 48 | $paramType = PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT; |
| | 49 | } |
| | 50 | $stmt->bindParam($bindKey, $paramValue, $paramType); |
| | 51 | } |
| | 52 | } |