Page 1 of 1
is there something wrong with this query?
Posted: Fri Jan 14, 2005 10:59 pm
by jasper
Code: Select all
$sql = "
SELECT G.level AS g_level, G.sp_cost, S.id, S.icon,
S.level AS s_level, S.active, S.magic, S.mp_consume, S.hp_consume,
S.range, S.skill_time, S.reuse_delay, S.effect, S.magic_level,
N.name, N.description
FROM GainSkills as G
JOIN Skills as S
ON (
( G.class_id = $class_infoїid] $ancestors )
AND G.level >= $class_infoїmin_level]
AND G.level <= $class_infoїmax_level]
AND G.skill_id = S.id
AND G.skill_level = S.level
)
LEFT JOIN SkillNames as N
ON ( S.id = N.id AND S.level = N.level AND N.language = '$l2dp_lang' )
ORDER BY G.level, S.active, N.name, S.level;";
Posted: Fri Jan 14, 2005 11:12 pm
by feyd
I'd guess this
but... mind explaining?

Posted: Sat Jan 15, 2005 9:55 am
by jasper
Hi thanks for the reply, that part does look a little weird. Well the original author gave his code away and right now, I'm just shiffting through them trying to get it to work. It was originally meant for postgre and I'm trying to get it to work on mysql.
This portion of the code has the $ancestors variable.
Code: Select all
$ancestors = "";
if ( strlen( $class_infoї'parents'] ) > 0 )
{
$par = split( ";", $class_infoї'parents'] );
foreach ( $par as $p )
{
// lookup class_id
$sql = "SELECT id FROM Classes WHERE name = '$p';";
$result = mysql_query( $sql, $dbc );
$lookup = mysql_fetch_array( $result );
$ancestors .= " OR class_id = " . $lookupї'id'];
}
}
Also, if you interested in seeing the whole php file, I changed skills.php into skills.txt so you can see in from my server at
http://personal.no-ip.org/lineage/skills.txt
Posted: Sat Jan 15, 2005 11:39 am
by magicrobotmonkey
Its often helpful to echo out the query so you can see what each variable is resolved to and if it breaks the query or not.