function flushcache(){
global $modx;
require_once $modx->config['base_path'].'manager/processors/cache_sync.class.processor.php';
$cache_sync = new synccache;
$cache_sync->setCachepath($modx->config['base_path'].'assets/cache/');
$cache_sync->emptyCache();
}

) here it is:
<?php
function flush_cache(){
global $modx;
include_once($modx->config['base_path'] . "manager/processors/cache_sync.class.processor.php");
$sync = new synccache();
$sync->setCachepath($modx->config['base_path'] . "assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
$modx->clearCache(); // double clear cache
}
?>
"id = {$e->params['id']}"$id = '.'.$_POST['id'];
// Update the database
$rows_affected = $modx->db->update(
$fields,
$table,
"id = {$e->params['id']}"
);
flush_cache();
It’s impossible to reliably get a row’s auto-incremented primary key value before it is inserted. You must be able to use getInsertId() after the insert statement takes place to get the id in the same request.
Sorry, I didn’t look what that getInsertId() actually did, I just remembered that it has been used in some snippets.. but now that I looked, it just returns the id of a previous insert statement. So, if you want the document ID before the document is inserted to the database, that wouldn’t work. You’d have to do a sql what finds out the max id number and ad one to it, but that will only work if no one else gets to create new documents in the meanwhile..
But could even the getInsertId() in theory return the wrong value if multiple documents were inserted at the same time by different requests..?
Quote from: doze at Jan 22, 2007, 03:13 PMIt’s impossible to reliably get a row’s auto-incremented primary key value before it is inserted. You must be able to use getInsertId() after the insert statement takes place to get the id in the same request.
Sorry, I didn’t look what that getInsertId() actually did, I just remembered that it has been used in some snippets.. but now that I looked, it just returns the id of a previous insert statement. So, if you want the document ID before the document is inserted to the database, that wouldn’t work. You’d have to do a sql what finds out the max id number and ad one to it, but that will only work if no one else gets to create new documents in the meanwhile..
But here’s how you can get the id of the newly created document: $modx->event->params[’id’]