SMF Support > vBulletin

Converting poll options

<< < (2/3) > >>

Oldiesmann:
I'm honestly not sure what the problem is with the votes.

This is the code SMF uses to get poll options and votes:


--- Code: ---$ignore = true;
$no_add = true;
$keys = array('id_poll', 'id_choice', 'label', 'votes');

$options = explode('|||', $row['options']);
$votes = explode('|||', $row['votes']);

$id_poll = $row['id_poll'];
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$rows[] = array(
'id_poll' => $id_poll,
'id_choice' => ($i + 1),
'label' => substr(addslashes($options[$i]), 1, 255),
'votes' => (is_numeric($votes[$i]) ? $votes[$i] : 0),
);
}
--- End code ---

The only problem I see is with the label - that "1" should be a "0" instead.

SMF sets it to 0 automatically if the value isn't numeric, so the IFNULL shouldn't make any difference.

cdesseno:
You were right with the label issue! (it is strange that nobody had noticed this bug before).
With the votes problem I think it should be solved with this:

--- Code: ---SELECT pollid AS id_poll, options, IFNULL( votes, 0 )[b] as votes[/b]
FROM foro_poll
--- End code ---

Is there any easy way just to run the poll's section of the converter?

cdesseno:
Here is the diff with my working version:


--- Code: ---< 'label' => substr(addslashes($options[$i]), 1, 255),
< 'votes' => (is_numeric($votes[$i]) ? $votes[$i] : 0),
---
> 'label' => substr(addslashes($options[$i]), 0, 255),
> 'votes' => (int) $votes[$i],

--- End code ---

Oldiesmann:
Did that fix the issue then?

cdesseno:
Yes!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version