PHP ADODB & amp; MySQL, параметры привязки

Я использую ADODB и MYSQL, пытаюсь выполнить инструкцию INSERT.

Хотя я прочитал много постов на форуме и узнал, что не могу связать параметры так же легко, как с oci8, я до сих пор не нашел пример, похожий на то, чего я пытаюсь достичь. Мой код выглядит следующим образом с oci8:

$street = $branch->getStreet();
$number = $branch->getNumber();
$city = $branch->getCity();
$state = $branch->getState();
$xMap = $branch->getXMap();
$yMap = $branch->getYMap();
$email = $branch->getEmail();

try{

//$this->db->debug = true;
$sql = "INSERT INTO branch ( nombre_branch, street, number, city, state, x_map, y_map, email ) VALUES (:branchName, :street, :number, :city, :state, :xMap, :yMap, :email)";
$sp = $this->db->PrepareSP($sql);

$this->db->InParameter($sp, $branchName, 'branchName');
$this->db->InParameter($sp, $street, 'street');
$this->db->InParameter($sp, $number, 'number');
$this->db->InParameter($sp, $city, 'city');
$this->db->InParameter($sp, $state, 'state');
$this->db->InParameter($sp, $xMap, 'xMap');
$this->db->InParameter($sp, $yMap, 'yMap');
$this->db->InParameter($sp, $email, 'email');

$rs = $this->db->Execute($sp);

} catch(ADODB_Exception $adodb_exception){
$logInfo['exception'] = $adodb_exception->getMessage();
$message = "'[".__CLASS__."] Error al executing ' insert '";if( !$this->rollbackTransaction()){
if(!is_null($this->log)) $this->log->log("ERROR in DB: ".print_r($logInfo, true), PEAR_LOG_ERR);
$message .= " Error in ROLLBACK.";

throw new DAODatabaseTransactionException ($message, $adodb_exception->getCode());
}
}
return $returnValue;
}

Спасибо!

0

Решение

Вот как я получил его для работы с MySQL без необходимости реализации PDO

 $sql = "INSERT INTO branch( branch_name, street, number, city, state, x_map, y_map, email) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";

$rs = $this->db->Execute($sql, array($branchName, $street, $number, $city, $state, $xMap, $yMap, $email));
$rs->Close();
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector