/** * @covers BindParam::__construct * @covers BindParam::getPhraseStr * @covers BindParam::getParamArray * @covers BindParam::getConditionStr */ public function testBindParam() { $cond_str = "condition string"; $phrase_str = "phrase string"; $param_array = array(1, 2, "3"); $param = new BindParam($param_array, $cond_str, $phrase_str); $actual = $param->getConditionStr(); $expected = $cond_str; $this->assertEquals($expected, $actual); $actual = $param->getParamArray(); $expected = $param_array; $this->assertEquals($expected, $actual); $actual = $param->getPhraseStr(); $expected = $phrase_str; $this->assertEquals($expected, $actual); }
/** * @param string $table * @param BindParam $params * @return bool|PDOResponse */ public function update($table, $params) { $sql = 'UPDATE ' . $table; $paramArray = array(); if ($params) { $phrase = $params->getPhraseStr(); //(field...)VALUES(:field...) $paramArray = $params->getParamArray(); if ($phrase != "") { $sql .= " SET {$phrase}"; } $condition = $params->getConditionStr(); if ($condition != "") { $sql .= " WHERE {$condition}"; } } return $this->pdo->prepAndExec($sql, $paramArray); }