Welcome Guest, Not a member yet? Register   Sign In
clear select
#1

(This post was last modified: 01-28-2023, 04:55 AM by futurewebs.)

Hi folks,
Using CI3
is there a way to clear / flush the select array ?

heres a basic example to try and explain better


PHP Code:
$this->db->select('user.*');


if (
$rs_type == 'small_select'){

// clear the select options and start again
 
$this->db->select('user.user_id'); // need to only select single item

 
$query $this->db->get('users');
 
$result $query->result();
 
 } else {

 
// here we select everything as normal

 
$query $this->db->get('users');
 
$result $query->result();

 } 


thanks in advance
Reply
#2

There is a 
PHP Code:
$this->db->reset_query() 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

would this not clear the whole query though rather than just the select element ?
Reply
#4

(01-28-2023, 06:05 AM)futurewebs Wrote: would this not clear the whole query though rather than just the select element ?

PHP Code:
<?php
// Not tested but i would go for something like this
$select = ( null !== $rs_type && 'small_select' == $rs_type ) ? 'user.user_id' 'user.*';
$query  $this->db->select($select)->get('users');

$result $query->result(); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB