| 6 | | class HermitProcedureResultSet { |
| | 6 | class HermitProcedureResultSet implements HermitResultSet, HermitParameterBind { |
| | 7 | private $procParameter; |
| | 8 | public function __construct(HermitProcedureParameter $procParameter){ |
| | 9 | $this->procParameter = $procParameter; |
| | 10 | } |
| | 11 | public function create(HermitStatement $stmt, HermitValueType $type){ |
| | 12 | $type->apply($stmt); |
| | 13 | |
| | 14 | if($stmt->columnCount() < 1){ |
| | 15 | return null; |
| | 16 | } |
| | 17 | |
| | 18 | $results = array(); |
| | 19 | do { |
| | 20 | $row = $stmt->fetch(); |
| | 21 | if(false === $row){ |
| | 22 | break; |
| | 23 | } |
| | 24 | $results[] = $row; |
| | 25 | } while($stmt->nextRowset()); |
| | 26 | return $results; |
| | 27 | } |
| | 28 | public function bindParameter(PDO $pdo, array $parameter){ |
| | 29 | $param = $parameter[0]; |
| | 30 | $dbms = HermitDatabaseMetaFactory::getDbms($pdo); |
| | 31 | if('mysql' === $dbms){ |
| | 32 | if(!$this->procParameter->hasBindParameters()){ |
| | 33 | return; |
| | 34 | } |
| | 35 | $out = $this->procParameter->getOutParameters(); |
| | 36 | foreach($out as $name){ |
| | 37 | $stmt = $pdo->prepare('SELECT @' . $name); |
| | 38 | $stmt->bindColumn(1, $param->$name); |
| | 39 | $stmt->execute(); |
| | 40 | |
| | 41 | $stmt->fetch(PDO::FETCH_BOUND); |
| | 42 | $stmt->closeCursor(); |
| | 43 | unset($stmt); |
| | 44 | } |
| | 45 | } |
| | 46 | } |