* -- defaults to listing data. with args.
*
* !colname=.... => colname != ....
- * colname[0]=... colname[1]=... => colname IN (.....)
+ * colname[0]=... colname[1]=... => colname IN (.....) ** only supports main table at present..
*
* other opts:
* _post = simulate a post with debuggin on.
function get($tab)
{
// $this->jerr("Not authenticated", array('authFailure' => true));
- //DB_DataObject::debuglevel(1);
+ // DB_DataObject::debuglevel(1);
// debugging...
if (!empty($_GET['_post'])) {
// do we really delete stuff!?!?!?
return $this->delete($x,$_REQUEST);
}
- print_r($_REQUEST);exit;
-
+
$old = false;
// collect tables
// echo '<PRE>';print_r($affects);exit;
- //DB_Dataobject::debugLevel(1);
+ //DB_Dataobject::debugLevel(1);
$clean = create_function('$v', 'return (int)$v;');
$bits = array_map($clean, explode(',', $req['_delete']));
// print_r($bits);exit;
+ $pk = $x->keys();
+ // let's assume it has a key!!!
+ $pk = $pk[0];
- $x->whereAdd('id IN ('. implode(',', $bits) .')');
- $x->find();
+ $x->whereAdd($pk .' IN ('. implode(',', $bits) .')');
+ if (!$x->find()) {
+ $this->jerr("Nothing found to delete");
+ }
$errs = array();
while ($x->fetch()) {
$xx = clone($x);
foreach($affects as $k=> $true) {
$ka = explode('.', $k);
$chk = DB_DataObject::factory($ka[0]);
- $chk->{$ka[1]} = $xx->id;
+ if (!is_a($chk,'DB_DataObject')) {
+ $this->jerr('Unable to load referenced table, check the links config: ' .$ka[0]);
+ }
+ $chk->{$ka[1]} = $xx->$pk;
if ($chk->count()) {
- $this->jerr('Delete Dependant records first');
+ $this->jerr('Delete Dependant records first ('. $ka[0]. ':' . $ka[1] .'='.$xx->$pk.')');
}
}
}
if (count($ar)) {
- $x->whereAddIn($key,$ar, $quote ? 'string' : 'int');
+ $x->whereAddIn($x->tableName(). '.'.$key,$ar, $quote ? 'string' : 'int');
}
continue;