diff options
author | Stanislav-Wolski <stanislau.wolski@gmail.com> | 2012-05-23 19:44:42 +0300 |
---|---|---|
committer | Stanislav-Wolski <stanislau.wolski@gmail.com> | 2012-05-23 19:44:42 +0300 |
commit | 6c5b0c64092ad095d55412b5765c14bd121b508c (patch) | |
tree | 9b2e598d9556f72e1eadc89f231074d7e7072085 /codebase/db_phpcake.php | |
parent | 97ec6d0772ca2123f54fb0cf558e9fe8a9b72115 (diff) | |
parent | 5b2915c991c6fd26503accfc7218256917bff0d3 (diff) | |
download | connector-php-6c5b0c64092ad095d55412b5765c14bd121b508c.zip connector-php-6c5b0c64092ad095d55412b5765c14bd121b508c.tar.gz connector-php-6c5b0c64092ad095d55412b5765c14bd121b508c.tar.bz2 |
Merge branch 'frameworks'
Conflicts:
codebase/base_connector.php
codebase/data_connector.php
codebase/grid_connector.php
codebase/scheduler_connector.php
Diffstat (limited to 'codebase/db_phpcake.php')
-rw-r--r-- | codebase/db_phpcake.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/codebase/db_phpcake.php b/codebase/db_phpcake.php new file mode 100644 index 0000000..980c9c3 --- /dev/null +++ b/codebase/db_phpcake.php @@ -0,0 +1,80 @@ +<?php +/* + @author dhtmlx.com + @license GPL, see license.txt +*/ +require_once("db_common.php"); + +//DataProcessor::$action_param ="dhx_editor_status"; + +/*! Implementation of DataWrapper for PDO + +if you plan to use it for Oracle - use Oracle connection type instead +**/ +class PHPCakeDBDataWrapper extends ArrayDBDataWrapper{ + public function select($sql){ + $res = $this->connection->find("all"); + if (sizeof($res)){ + $name = get_class($this->connection); + $temp = array(); + for ($i=sizeof($res)-1; $i>=0; $i--) + $temp[]=&$res[$i][$name]; + } + return new ArrayQueryWrapper($temp); + } + + protected function getErrorMessage(){ + $errors = $this->connection->invalidFields(); + $text = array(); + foreach ($errors as $key => $value){ + $text[] = $key." - ".$value[0]; + } + return implode("\n", $text); + } + + public function insert($data,$source){ + $name = get_class($this->connection); + $save = array(); + $temp_data = $data->get_data(); + unset($temp_data[$this->config->id['db_name']]); + unset($temp_data["!nativeeditor_status"]); + $save[$name] = $temp_data; + + if ($this->connection->save($save)){ + $data->success($this->connection->getLastInsertID()); + } else { + $data->set_response_attribute("details", $this->getErrorMessage()); + $data->invalid(); + } + } + public function delete($data,$source){ + $id = $data->get_id(); + $this->connection->delete($id); + $data->success(); + } + public function update($data,$source){ + $name = get_class($this->connection); + $save = array(); + $save[$name] = &$data->get_data(); + + if ($this->connection->save($save)){ + $data->success(); + } else { + $data->set_response_attribute("details", $this->getErrorMessage()); + $data->invalid(); + } + } + + + public function escape($str){ + throw new Exception("Not implemented"); + } + public function query($str){ + throw new Exception("Not implemented"); + } + public function get_new_id(){ + throw new Exception("Not implemented"); + } +} + +?>
\ No newline at end of file |