function get_labels_from_table($db, $table_name) { \k1lib\sql\db_check_object_type($db, __FUNCTION__); if (!is_string($table_name) || empty($table_name)) { die(__FUNCTION__ . " \$table_name should be an non empty string"); } $table_config_array = \k1lib\sql\get_db_table_config($db, $table_name); $label_field = \k1lib\sql\get_db_table_label_fields($table_config_array); $table_keys_array = \k1lib\sql\get_db_table_keys($table_config_array); if (!empty($table_keys_array)) { $table_config_array = array_flip($table_keys_array); } if (count($table_keys_array) === 1) { $key_filed = key($table_keys_array); $labels_sql = "SELECT {$key_filed} as value, {$label_field} as label FROM {$table_name}"; $labels_data = \k1lib\sql\sql_query($db, $labels_sql); if (!empty($labels_data) && count($labels_data) > 0) { $label_array = array(); foreach ($labels_data as $row) { $label_array[$row['value']] = $row['label']; } return $label_array; } else { return FALSE; } } else { return FALSE; } }
private static function _get_db_table_label_fields(&$db_table_config) { return \k1lib\sql\get_db_table_label_fields($db_table_config); }
public function remove_labels_from_data_filtered($row = 1) { if ($this->db_table_data) { $label_fields_array = \k1lib\sql\get_db_table_label_fields($this->db_table->get_db_table_config()); foreach ($label_fields_array as $field) { unset($this->db_table_data_filtered[$row][$field]); } } }