}
 $group_name = strval(@$tab['group']);
 if (!$nogroups) {
     $group_key = array_search($group_name, $groups_xlat, true);
     if ($group_key === false) {
         $groups_xlat[] = $group_name;
         end($groups_xlat);
         $group_key = key($groups_xlat);
         // = the same as count($groups_xlat)-1, but...
         // just in case PHP changes its algorithm
     }
 }
 if (!isset($json_groups[$group_key])) {
     $json_groups[$group_key] = array('name' => $group_name, 'tables' => array());
 }
 $name = strlen(@$tab['name']) > 0 ? strval($tab['name']) : TableClass::ident_to_name($tab['table']);
 $icon = strval(@$tab['icon']);
 if ($tab['table'] === '*') {
     $tab_obj = new TableClass($table_key);
     if ($tab_obj->src_type != TableClass::TYPE_PDO) {
         throw new Exception(sprintf($tab_obj->error_sprintf, "Can't retrieve all tables for a non-relational-database (SQL) data source ['table'] in"));
     }
     $pdo_s = $tab_obj->src->query("SHOW TABLES");
     foreach ($pdo_s->fetchAll(PDO::FETCH_COLUMN, 0) as $tab_name) {
         if (!preg_match('/\\A[a-zA-Z_][a-zA-Z0-9_]*\\z/', $tab_name)) {
             continue;
         }
         $json_groups[$group_key]['tables'][] = array('table_key' => "{$table_key}|{$tab_name}", 'name' => $name, 'icon' => $icon);
     }
 } else {
     $json_groups[$group_key]['tables'][] = array('table_key' => $table_key, 'name' => $name, 'icon' => $icon);
Exemple #2
0
 $row = $pdo_s->fetch(PDO::FETCH_ASSOC);
 if ($row !== false) {
     /*
      * TODO: Uncomment when we take the time to filter only used parameters!
      * (currently, values here that are not used cause PDO exception!)
     // prepare argument to PDO prepare, if it ever may be needed
     if( count($options_pending_sql) > 0 )
     	{
     	foreach( $row as $col => $value )
     		$opt_pdo_params[":$col"] = $value;
     	}
     */
     // read each column
     foreach ($row as $col => $value) {
         if ($auto_cols) {
             $json_columns[] = array('column' => $col, 'name' => TableClass::ident_to_name($col), 'control' => "text");
             end($json_columns);
             $names_xlat[$col] = key($json_columns);
             // = the same as count($json_row)-1, but...
             // just in case PHP changes its algorithm
         }
         if (!$no_req_ids) {
             if (isset($names_xlat[$col])) {
                 if ($json_columns[$names_xlat[$col]]['control'] == "number") {
                     $value = strpos($value, '.') !== false ? floatval($value) : intval($value);
                 }
                 // required otherwise the "number" control won't display this!
                 $json_columns[$names_xlat[$col]]['value'] = $value;
             } else {
                 if (isset($button_columns[$col])) {
                     $button_columns[$col][0] = $value;
Exemple #3
0
 $json_row_cols['col_id'] = $config_ids;
 $json_row_cols['col_list'] = $config_list_cols;
 foreach ($config_list_cols as $col) {
     $name = @$tab['col_names'][$col];
     if (is_array($name)) {
         $name = @$name[0];
     }
     if ($name === NULL) {
         $name = TableClass::ident_to_name($col);
     }
     $json_row_cols['names_list'][] = strval($name);
 }
 // Prepare list of columns values to match/filter
 $req_col_values = $tab_obj->req_col_values();
 // Setup common `$json` properties
 $json['name'] = isset($tab['name']) ? strval($tab['name']) : TableClass::ident_to_name(@$tab['table']);
 $json['can_edit'] = intval(@$tab['editable']) & (TableClass::NOT_EDITABLE | TableClass::EDITABLE_ON_REQUEST | TableClass::EDITABLE_IMMEDIATELY);
 $json['can_insert'] = (intval(@$tab['editable']) & TableClass::CAN_INSERT) != 0;
 $json['can_delete'] = (intval(@$tab['editable']) & TableClass::CAN_DELETE) != 0;
 // Rows, etc.
 $req_do_count = isset($_POST['count']);
 $req_row_start = is_numeric(@$_POST['row_start']) ? intval($_POST['row_start']) : false;
 $req_row_limit = is_numeric(@$_POST['row_limit']) ? intval($_POST['row_limit']) : false;
 $req_search = strlen(@$_POST['search']) > 0 ? strval($_POST['search']) : false;
 //
 if ($req_row_start < 0 || $req_row_limit < 0) {
     throw new \Exception("{$tab_obj->error_script} called with negative row_start or row_limit.");
 }
 if ($req_search !== false) {
     throw new \Exception("Searches not yet supported (when calling {$tab_obj->error_script}).");
 }