public function restIndexScaffold()
 {
     $adapter = Api::_()->getDbAdapter();
     $metadata = new Metadata($adapter);
     $tables = $metadata->getTableNames();
     return array('tables' => $tables);
 }
 public function restGetItem()
 {
     $query = $this->getRequest()->getQuery();
     $tab = $this->getEvent()->getRouteMatch()->getParam('id');
     $adapter = Api::_()->getDbAdapter();
     $metadata = new Metadata($adapter);
     $columns = $metadata->getColumns($tab);
     $props = array('name', 'ordinal_position', 'column_default', 'is_nullable', 'data_type', 'character_maximum_length', 'character_octet_length', 'numeric_precision', 'numeric_scale', 'numeric_unsigned', 'erratas', 'column_type');
     foreach ($columns as $column) {
         $columnName = $column->getName();
         foreach ($props as $prop) {
             $res[$columnName][$prop] = $column->{'get' . str_replace('_', '', $prop)}();
         }
     }
     return array('columns' => $res, 'table' => $tab);
 }
 public function check($elementName)
 {
     if ($this->columns) {
         $res = $this->columns;
     } else {
         $tabs = array("eva_user_users", "eva_user_profiles");
         $adapter = Api::_()->getDbAdapter();
         $metadata = new Metadata($adapter);
         foreach ($tabs as $tab) {
             $columns = $metadata->getColumns($tab);
             foreach ($columns as $column) {
                 $columnName = $column->getName();
                 $res[$columnName] = $columnName;
             }
         }
         $this->columns = $res;
     }
     return empty($res[$elementName]) ? false : true;
 }