Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Biology Forums - helmikuu 04, 2014, 08:50:39 IP

Otsikko: SMF 2.x Database Code conversation to SMF 1.x
Kirjoitti: Biology Forums - helmikuu 04, 2014, 08:50:39 IP
$result_shop = $smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET cash = cash + {int:points}
WHERE id_member = {int:member}
LIMIT 1',
array(
'member' => $user_info['id'],
'points' => $points,

)
);


I want this to be changed back to SMF 1.x

I know SMF 1.x uses: db_query(" and ", __FILE__, __LINE__);, but how do I use that here.
Otsikko: Re: SMF 2.x Database Code conversation to SMF 1.x
Kirjoitti: live627 - helmikuu 05, 2014, 12:27:53 AP
db_query("
            UPDATE {$db_prefix}members
             SET cash = cash + $points
             WHERE id_member = $user_info[id]
             LIMIT 1", __FILE__, __LINE__);
Otsikko: Re: SMF 2.x Database Code conversation to SMF 1.x
Kirjoitti: margarett - helmikuu 05, 2014, 01:17:30 IP
I did a quick test here and, in 1.1, $user_info actually has no "id" ???
$context['user'] has "id" but it might not be available everywhere.
Otsikko: Re: SMF 2.x Database Code conversation to SMF 1.x
Kirjoitti: Biology Forums - helmikuu 05, 2014, 05:52:41 IP
Thanks guys, I figured it out.
Otsikko: Re: SMF 2.x Database Code conversation to SMF 1.x
Kirjoitti: margarett - helmikuu 05, 2014, 05:56:28 IP
Care to share? ;)
Otsikko: Re: SMF 2.x Database Code conversation to SMF 1.x
Kirjoitti: Biology Forums - helmikuu 05, 2014, 06:04:02 IP
// Earn shop credits everytime you play, but exclude guests (they don't get shop credits anyway)
if (!$user_info['is_guest'])
{
$points = 2;
db_query("
UPDATE {$db_prefix}members
SET money = money + $points
WHERE ID_MEMBER = $ID_MEMBER
", __FILE__, __LINE__);
}