public function getIdsFromConditions($rows, $conditions, $limit = null)
    {
        $withLimit = !is_null($limit) && (is_array($limit) && !is_null($limit[0]));
        if ($withLimit) {
            $max = is_null($limit[1]) ? $limit[0] : ($limit[0] + $limit[1]);
        }

        $ids = array();
        foreach ($rows as $id => $row) {
            if ($id === '__ids__') {
                continue;
            }

            $valid = true;
            foreach ($conditions as $c) {
                if (!$this->isValid($row, $c)) {
                    $valid = false;
                    break;
                }
            }
            if ($valid === true) {
                $ids[] = $id;
                if ($withLimit && isset($max) && count($ids) > $max) {
                    break;
                }
            }
        }
        if ($withLimit) {
            if ($limit[1] === null) {
                $ids = array_slice($ids, 0, $limit[0]);
            } else {
                $ids = array_slice($ids, $limit[0], $limit[1]);
            }
        }

        return $ids;
    }