xoops forums

ramoneariel

Just popping in
Posted on: 2008/3/27 14:34
ramoneariel
ramoneariel (Show more)
Just popping in
Posts: 6
Since: 2005/11/23
#1

problem with $xoopsDB->prefix()

I'v problem with $xoopsDB->prefix() in a consult to DB with a subconsult.

Sorry for my english.

This's the sentence

$result = $xoopsDB->queryF("SELECT v_venta_nro FROM ".$xoopsDB->prefix("ventas")." WHERE id = (SELECT MAX(id) FROM ".$xoopsDB->prefix("ventas")." LIMIT 1 )ORDER BY id DESC") ;

$row = mysql_fetch_array($result);

nachenko

Quite a regular
Posted on: 2008/3/27 14:52
nachenko
nachenko (Show more)
Quite a regular
Posts: 356
Since: 2005/1/18
#2

Re: problem with $xoopsDB->prefix()

Why don't you put the prefixed table name in a variable instead of executing the prefix method twice?

Like this:

$ventas_table = $xoopsDB->prefix('ventas');

then

$result = $xoopsDB->queryF("SELECT v_venta_nro FROM $ventas_table WHERE id = (SELECT MAX(id) FROM $ventas_table LIMIT 1 )ORDER BY id DESC") ;

ramoneariel

Just popping in
Posted on: 2008/3/27 16:11
ramoneariel
ramoneariel (Show more)
Just popping in
Posts: 6
Since: 2005/11/23
#3

Re: problem with $xoopsDB->prefix()

Ok, Gracias. De esta manera funciona, pero no deberia tener que hacerlo.