Location: PHPKode > projects > Eventum > eventum-2.2/misc/upgrade/v1.5.5_to_v1.6.0/upgrade_saved_searches.php
<?php
require_once(dirname(__FILE__) . "/../../../init.php");
require_once(APP_INC_PATH . "db_access.php");

$sql = "SELECT
            cst_id,
            cst_prj_id,
            cst_keywords,
            cst_customer_email
        FROM
            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_filter";
$res = $GLOBALS["db_api"]->dbh->getAll($sql, DB_FETCHMODE_ASSOC);
if (PEAR::isError($res)) {
	echo 'ERROR: ', $res->getMessage(), ': ', $res->getDebugInfo(), "\n";
    exit(1);
}
foreach ($res as $row) {
    if (!empty($row['cst_customer_email'])) {
        $search_type = 'customer';
        $keywords = $row['cst_customer_email'];
    } else {
        $search_type = 'all_text';
        $keywords = $row['cst_keywords'];
    }
    $sql = "UPDATE
                " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_filter
            SET
                cst_search_type = '$search_type',
                cst_keywords = '" . Misc::escapeString($keywords) . "'
            WHERE
                cst_id = " . $row['cst_id'];
    $res = $GLOBALS["db_api"]->dbh->query($sql);
    if (PEAR::isError($res)) {
		echo 'ERROR: ', $res->getMessage(), ': ', $res->getDebugInfo(), "\n";
        exit(1);
    } else {
        echo "Setting saved search #" . $row['cst_id'] . " to type $search_type<br />\n";
    }
}
?>
done
Return current item: Eventum