[eluser]Sally D[/eluser]
ok I am trying insert a multidimensional array it looks like this
array('from'=>array(1,2,3,4),'subject'=>array(1,2,3,4), 'body'=>array(1,2,3,4));
into a database set up like this
id (int) primary key,
from text,
subject text,
body text,
no my problem is when ever I do
$this->db->set(array(from=>$from,subject=>$subject,body=>$body));
$this->db->insert('email')
I get an mysql error 1064 is it me or mysql i don't know
here is the code I am working with
This is my model
Code:
<?
class Email2Db extends Model {
function Email2Db()
{
parent::Model();
}
function saveEmail($email)
{
/*
this simple test is not working I am getting a mysql database 1064
$this->db->set(array('from'=>'ray','subject'=>'test','body'=>'test body'));
$this->db->insert('email');
*/
/* I want to use this code to update my data base with a multidimentional array that will be passed in from the saveEmail function and it just ain't working I don't know if its the code or mysql the simple test above to work either */
$feildArray = array('from','subject','body');
for($i = 1; $i <= sizeOf($email['body']); $i++)
{
foreach($feildArray as $val)
{
$$val = $email[$val][$i];
$this->db->set($val,${$val});
}
$this->db->insert('email');
}
}
}
?>
and here is my controller
Code:
function index()
{
$email = $this->mob->get_email();
$this->email2db->saveEmail($email);
}
Right now I don't know if its the code or if its mysql. Am I calling the $this->db->set function wrong. I'm getting delusional please help thanks alot.