* ... call $roo->jerr() on failure...
*
* BEFORE
- * - beforeDelete($dependants_array, $roo) Argument is an array of un-find/fetched dependant items.
+ * - beforeDelete($dependants_array, $roo, $request) Argument is an array of un-find/fetched dependant items.
* - jerr() will stop insert.. (Prefered)
* - return false for fail and set DO->err;
* - beforeUpdate($old, $request,$roo) - after update - jerr() will stop insert..
// sets map and countWhat
$this->loadMap($x, array(
- 'columns' => $_columns,
- 'distinct' => empty($_REQUEST['_distinct']) ? false: $_REQUEST['_distinct'],
- 'exclude' => empty($_REQUEST['_exclude_columns']) ? false: explode(',', $_REQUEST['_exclude_columns'])
- ));
+ 'columns' => $_columns,
+ 'distinct' => empty($_REQUEST['_distinct']) ? false: $_REQUEST['_distinct'],
+ 'exclude' => empty($_REQUEST['_exclude_columns']) ? false: explode(',', $_REQUEST['_exclude_columns'])
+ ));
$this->setFilters($x,$_REQUEST);
//print_r($x);
// build join if req.
//DB_DataObject::debugLevel(1);
- // var_dump($this->countWhat);
- $total = $x->count($this->countWhat);
+ // count with multiple joins and no conditions can be quite slow - so if there are no conditions - just remove the joins from the count.
+ $xx = clone($x);
+ $old_where = $x->whereAdd();
+ if (empty($old_where )) {
+ $xx->_join = '';
+ } else {
+ $x->whereAdd($old_where);
+ $xx=clone($x);
+
+ }
+
+ $total = $xx->count($this->countWhat);
// sorting..
//
//var_dump($total);exit;
* - return false for fail and set DO->err;
*
* beforeUpdate($old, $request,$roo)
- * - after update - jerr() will stop insert..
+ * - before update - jerr() will stop insert..
* beforeInsert($request,$roo)
* - before insert - jerr() will stop insert..
*
$ms ? json_decode($ms) : false
);
}
+
if ($ms !== false) {
return $this->multiSort($x);
}
-
+
if ($sorted === false) {
-
$cols = $x->tableColumns();
$excols = array_keys($this->cols);
if (method_exists($x, 'toRooArray')) {
$this->jok($x->toRooArray($req));
}
-
$this->jok($x->toArray());
function insert($x, $req, $with_perm_check = true)
{
+
if (method_exists($x, 'setFromRoo')) {
$res = $x->setFromRoo($req, $this);
if (is_string($res)) {
} else {
$x->setFrom($req);
}
-
+
if ( $with_perm_check && !$this->checkPerm($x,'A', $req)) {
$this->jerr("PERMISSION DENIED (i)");
}
}
$ev = $this->addEvent("ADD", $x);
if (method_exists($x, 'onInsert')) {
+
$x->onInsert($_REQUEST, $this, $ev);
}
if ($ev) {
$ev->audit($x);
}
-
+
// note setFrom might handle this before hand...!??!
if (!empty($_FILES) && method_exists($x, 'onUpload')) {
$x->onUpload($this, $_REQUEST);
$match_total = 0;
if ( $has_beforeDelete ) {
- if ($xx->beforeDelete($match_ar, $this) === false) {
+ if ($xx->beforeDelete($match_ar, $this, $_REQUEST) === false) {
$errs[] = "Delete failed ({$xx->id})\n".
(isset($xx->err) ? $xx->err : '');
continue;
$x->whereAdd("(on_id = $oid OR
on_id IN ( SELECT distinct(id) FROM Documents WHERE original = $o )
)");
- continue;
+ continue 2;
}
$x->on_id = $val;
// the aobve rule for !strlen non-joined cols should apply to joined ones.
if (!strlen($val)) {
- continue;
+ continue 2;
}
}
- continue;
+ continue 2;
}
}
if (!empty($q_filtered)) {