Recientemente he tenido la necesidad de integrar el cms d ecommerce 'opencart' con flex builder 4 (para los no q sepan q es flex, es un framework d flash q permite el desarrollo d RIAs), una nueva funcion d flex es q ahora con solo unos simples pasos flex se puede conectar a una BD autogenerando todo el codigo.
Ya pude conectarme a la BD y hacer operaciones con casi todas sus tablas d manera exitosa, pero hay una tabla con la q no he podido hacer ninguna operacion, la tabla tiene 50 comlunas, tiene solo 1 registro.
Aqui esta primeramente como se hace la llamada:
(Este codigo lo auto-genera flex)
Código PHP:
public function getOrderByID($itemID) {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where order_id=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, $itemID);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_bind_result($stmt, $row->order_id, $row->invoice_id, $row->invoice_prefix, $row->store_id, $row->store_name, $row->store_url, $row->customer_id, $row->customer_group_id, $row->firstname, $row->lastname, $row->telephone, $row->fax, $row->email, $row->shipping_firstname, $row->shipping_lastname, $row->shipping_company, $row->shipping_address_1, $row->shipping_address_2, $row->shipping_city, $row->shipping_postcode, $row->shipping_zone, $row->shipping_zone_id, $row->shipping_country, $row->shipping_country_id, $row->shipping_address_format, $row->shipping_method, $row->payment_firstname, $row->payment_lastname, $row->payment_company, $row->payment_address_1, $row->payment_address_2, $row->payment_city, $row->payment_postcode, $row->payment_zone, $row->payment_zone_id, $row->payment_country, $row->payment_country_id, $row->payment_address_format, $row->payment_method, $row->comment, $row->total, $row->order_status_id, $row->language_id, $row->currency_id, $row->currency, $row->value, $row->coupon_id, $row->date_modified, $row->date_added, $row->ip);
if(mysqli_stmt_fetch($stmt)) {
$row->date_modified = new DateTime($row->date_modified);
$row->date_added = new DateTime($row->date_added);
return $row;
} else {
return null;
}
}
Aqui esta la funcion throwExceptionOnError() (Por si alguien pregunta d donde salio '$this->throwExceptionOnError()'):
Código PHP:
private function throwExceptionOnError($link = null) {
if($link == null) {
$link = $this->connection;
}
if(mysqli_error($link)) {
$msg = mysqli_errno($link) . ": " . mysqli_error($link);
throw new Exception('MySQL Error - '. $msg);
}
}
Y aqui el error q me manda:
Código:
Soy practicamente nuevo usando php y nuevo en mysql, se programar y por lo q he revisado no tengo ningun error en la sintaxis.InvocationTargetException:There was an error while invoking the operation. Check your server settings and try invoking the operation again. Reason: Server error MySQL Error - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order where order_id=?' at line 1 #0 C:\wamp\www\opencart\pruebaopencart\services\OrderService.php(93): OrderService->throwExceptionOnError() #1 [internal function]: OrderService->getOrderByID(1) #2 [internal function]: ReflectionMethod->invokeArgs(Object(OrderService), Array) #3 C:\wamp\www\ZendFramework\library\Zend\Server\Reflection\Function\Abstract.php(368): call_user_func_array(Array, Array) #4 [internal function]: Zend_Server_Reflection_Function_Abstract->__call('invokeArgs', Array) #5 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(356): Zend_Server_Reflection_Method->invokeArgs(Object(OrderService), Array) #6 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(550): Zend_Amf_Server->_dispatch('getOrderByID', Array, 'OrderService') #7 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(626): Zend_Amf_Server->_handle(Object(Zend_Amf_Request_Http)) #8 C:\wamp\www\opencart\pruebaopencart\gateway.php(69): Zend_Amf_Server->handle() #9 {main}
A alguien se le ocurre por q sucede esto?
Saludos y muchas gracias.