Quote from: BobRay at Jul 30, 2013, 06:02 PMThat makes sense and my suggestion no longer does. 
Let me try again. You need a unique 'id' field in your table that should be the primary key and set to autoincrement, and you need a <field key="id" line in your schema if you're extending xPDOObject, but not if you're extending xPDOSimpleObject. Maybe your schema was created before the 'id' field existed?
The 'id' field existed all along, but I think because I used the generated classes first it just worked (extending xPDOSimpleObject, like you said). When I tried using the tutorials approach this probably didn't work anymore because of conflicts in the class when extending (not that good with php)?
Before the tutorial it did work (as well on the front-end as in the manager), but I wanted to be able to manage/edit registrations. So I tried using the tutorial to create controllers, a connector and processors. Before I had only a connector which looked like:
/**
* Controller for Ajax requests.
*/
// Adjust the path appropriately
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
if (!defined('MODX_API_MODE')) {
define('MODX_API_MODE', false);
}
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
if (!$modx->hasPermission('view_document')) {
header('HTTP/1.0 401 Unauthorized');
print 'Operation not allowed.';
exit;
}
// These are the standard values that are posted to the Ajax URL by Ext JS
$start = (int) $modx->getOption('start',$_POST,0);
$limit = (int) $modx->getOption('limit',$_POST,20);
$sort = $modx->getOption('sort',$_POST);
$dir = $modx->getOption('dir',$_POST,'ASC');
// error_log(print_r($_POST,true)); // <--- uncomment this for debugging
$path = MODX_CORE_PATH . 'components/inschrijvingen/';
$result = $modx->addPackage('inschrijvingen',$path . 'model/','evd_');
$c = $modx->newQuery('Inschrijvingen');
$count = $modx->getCount('Inschrijvingen',$c);
$pages = $modx->getCollection('Inschrijvingen');
$c->sortby($sort,$dir);
$c->limit($limit,$start);
//$c->prepare(); error_log($c->toSQL()); // <-- uncomment for debugging
//$pages = $modx->getCollection('modResource',$c);
$list = array();
foreach ($pages as $p) {
$array = $p->toArray();
$list[] = $array;
}
// The format of the output is not well documented, but it requires a node for "total" and "rows"
print '{"total":"'.$count.'","results":'.$modx->toJSON($list).',"success":true,"msg":"Got our rows..."}';
//error_log(print_r($list,true)); // <-- another debugging point
@session_write_close();
exit();
You will probably recognize this, because it is from your tutorial.
Also, you do know that you need to re-run the script any time the schema changes, right? That's necessary to update the class and map files.
Yup, did it a few times already (forgot some fields, made some mandatory etc). It's a fantastic snippet!