public function delete() { $bdd = Bdd::getInstance(); if (!$this->isnew) { $pf = $this->model->getPrimaryField(); $pv = $this->get($pf); $bdd->delete($this->model->getTableName(), $pf, $pv); $this->isnew = true; } }
public function formatOut($value) { $bdd = Bdd::getInstance(); return $bdd->formatOut($this->getType(), $value); }
protected function get_foreign($r) { Input::ensureRequest($r, array("name")); $name = $r["name"]; $field = $this->model->getField($name); $bdd = Bdd::getInstance(); list($table, $key, $value) = $field->getForeign(); $foreignModel = Model::getModel($table); $col = Collection::Query($table)->SelectAs($bdd->quoteIdent($key), $bdd->quoteIdent('key'))->SelectAs($bdd->quoteIdent($value), $bdd->quoteIdent('val'))->orderBy($bdd->quoteIdent($value))->limit($this->options["limit"]); if (Input::has("q") && strlen(Input::get("q")) > 0) { $col->filter(Input::get("q")); } $this->filterForeign($col, $field); $list = []; foreach ($col->getValues(Input::has("p") ? intval(Input::get("p")) : 0) as $row) { if ($foreignModel) { $list[] = array("key" => $foreignModel->getField($key)->formatOut($row['key']), "value" => $foreignModel->getField($value)->formatOut($row['val'])); } else { $list[] = array("key" => $row['key'], "value" => $row['val']); } } Output::success(array("list" => $list)); }
public function getBy($field, $value) { $bdd = Bdd::getInstance(); if (array_key_exists($field, $this->fields)) { return $this->simpleSelect(array($bdd->quoteIdent($field) . "=:value"), array("value" => $value)); } throw new Exception("Field {$field} not found"); }