Hello,
I’m a newbie with Yii and want to port my old project to Yii.
I have this code:
$q =
"SELECT `left`, `right`
FROM `tree`
WHERE CONCAT(INET_NTOA(IP), '/', (IF(LOCATE(0, BIN(Mask)) <> 0, LOCATE(0, BIN(Mask))-1, 32))) LIKE '%".$search."%'";
$db->query($q);
if($db->nf() === 0)
{
return "[]";
}
$q = "SELECT DISTINCT `id` FROM `tree` WHERE 0 ";
while($db->nextr())
{
$q .= " OR (`left` < ".(int)$db->f(0)." AND `right` > ".(int)$db->f(1).") ";
}
$result = array();
$db->query($q);
while($db->nextr())
{
$result[] = "#node_".$db->f(0);
}
What would be the best way, performance and operation wise to get same from Yii?