php - Removing null columns in SQL query -


i'm using select * query table.

$query = $this->db->get($table_name); 

what want discard records value column empty example

array  {    topic_1 ->    topic_2 -> cats } 

it discard topic_1 key , value pair entirely. i'm using codeigniter active record tried doing

$query = $this->db->get_where($value, array(test_id != 'null')); 

but cannot specify each column, want test_id columns in table? there can or can run loop after query returned discards unmatched key value pairs?

first, doing null wrong. should go this:

$query = $this->db->where('test_id !=', null)->get($value)->result_array(); 

that query work when field null, in case not null, empty. in order field null must specify default when creating table. query case be:

$query = $this->db->where('test_id !=', '')->get($value)->result_array(); 

for fields, guess need go foreach loop:

$data = array(); $field = array('field1', 'field2', ...); foreach($field $f) : $query = $this->db->where($f, '')->get('table')->result_array(); $data = $data + $query; endforeach; 

this way in $data field empty.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -