Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

Problema con muchas columnas....

Estas en el tema de Problema con muchas columnas.... en el foro de Mysql en Foros del Web. Hola amigos, antes que nada me presento soy px87 y soy d México. Recientemente he tenido la necesidad de integrar el cms d ecommerce 'opencart' ...
  #1 (permalink)  
Antiguo 28/10/2010, 21:01
 
Fecha de Ingreso: octubre-2010
Mensajes: 8
Antigüedad: 13 años, 6 meses
Puntos: 5
Problema con muchas columnas....

Hola amigos, antes que nada me presento soy px87 y soy d México.

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:
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}
Soy practicamente nuevo usando php y nuevo en mysql, se programar y por lo q he revisado no tengo ningun error en la sintaxis.

A alguien se le ocurre por q sucede esto?

Saludos y muchas gracias.
  #2 (permalink)  
Antiguo 29/10/2010, 03:18
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: Problema con muchas columnas....

Es muy probable que al menos uno de los parámertos esté llegando vacío.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #3 (permalink)  
Antiguo 01/11/2010, 09:24
 
Fecha de Ingreso: octubre-2010
Mensajes: 8
Antigüedad: 13 años, 6 meses
Puntos: 5
Respuesta: Problema con muchas columnas....

Solucionado!!!

Lo q hice fue cambiar esto:

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(); 

Por esto:

Código PHP:
    public function getOrderByID($x) {
        
        
        
$sql "SELECT * FROM `order` where order_id LIKE '%$x%'";
        
        
        
$stmt mysqli_prepare($this->connection$sql);
        
$this->throwExceptionOnError();
        
        
mysqli_stmt_execute($stmt);
        
$this->throwExceptionOnError(); 
Este cambio en el codigo autogenerado lo hice hace tiempo para otros fines.

La verdad no soy muy diestro con PHP, me da un poco d pena pedir esto jeje, me podrian explicar por q me funciono, osea, cual es la diferencia entre uno y otro codigo?

Saludos y muchas gracias.

Última edición por px87; 01/11/2010 a las 13:06

Etiquetas: columnas, muchas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:35.