/** * @test * @covers Cocur\NQM\QueryHelper::convertParameters() */ public function convertParametersAddsColonToParameter() { $params = QueryHelper::convertParameters(['foo' => 'bar', 'qoo' => 'baz']); $this->assertArrayHasKey(':foo', $params); $this->assertArrayHasKey(':qoo', $params); $this->assertArrayNotHasKey('foo', $params); $this->assertArrayNotHasKey('qoo', $params); }
/** * @param string $name * @param array $parameters * @param array $options * * @return StatementCollection */ public function execute($name, $parameters = [], $options = []) { $pdo = $this->nqm->getPdo(); $statements = new StatementCollection(); foreach ($this->getQueries($name) as $index => $query) { $statement = $pdo->prepare($query, $options); foreach ($this->getQueryParameters($query, QueryHelper::convertParameters($parameters)) as $key => $value) { $statement->bindValue($key, $value); } $statement->execute(); $statements->add($statement); } return $statements; }