• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use of Unique in mySQL field cases Error

#21
I am trying to use this one again in MyModel:
public function insertIgnore(array $data)
{
$_prepared = array();
foreach ($data as $col => $val)
{
$_prepared[$this->db->_escape_identifiers($col)] = $this->db->escape($val);
}
$this->db->query('INSERT IGNORE INTO `exclude_choices` ('.implode(',',array_keys($_prepared)).') VALUES('.implode(',',array_values($_prepared)).');');
}

I modified $_prepared[_escape_identifiers($col)] = escape($val); to get rid of the $this->db. Now I get "call to undefined function _escape_identifiers()".

Any idea?
proof that an old dog can learn new tricks
Reply

#22
PHP Code:
// Usage:

// Use this if the database is not loaded
// or autoloaded.
$this->load->database();

$table 'titles';

$data = array(
    'item'     => $post_array['employee_title'],
    'campaign' => $this->session->userdata('campaign'),
    'userid'   => $this->session->userdata('userid')
);

$sql $this->db->set($data)->get_compiled_insert($table);
$sql str_replace('INSERT INTO''INSERT IGNORE INTO'$sql);
$this->db->query($sql); 

You should not need to load the database if it is autoloaded.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#23
OK. Tried using db-> as per your suggestion and it seems to work. Thanks again....
proof that an old dog can learn new tricks
Reply

#24
If it's working make sure you change the title of this post to [SOLVED] for others.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.