• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[please help]this SQL syntax make me crazy

#1
[eluser]rikes_denis[/eluser]
i'm trying to insert a value to my database, everything is fine except the inserting thing. this is my controller function

Code:
$items = $this->okapi_termmodel->get_term()->result();
        var_dump($items);
        $insertIDF = 'INSERT INTO okapi_term(idf) VALUES(?)';
        foreach($items as $item) {
            $this->db->query($insertIDF, $this->idf($item->term));
            }

when i var_dump the $items, it shows all the database perfectly.
but in the end it return this error

Quote:A Database Error Occurred


Error Number: 1062

Duplicate entry '' for key 'term'

INSERT INTO okapi_term(idf) VALUES(-2.1972245773362)

can someone help me???
thanx b4

#2
[eluser]boltsabre[/eluser]
Just off the top of my head, perhaps your have your table column set to only accept unique values, and your trying to insert a value that already exists in the table? Or try investigating what Error Number 1062 means in detail.

#3
[eluser]rikes_denis[/eluser]
no, im not settings a unique value in my database
im still trying search the web.

the id is auto increment and bigint type, is this might be a problem?

#4
[eluser]troy_mccormick[/eluser]
[quote author="rikes_denis" date="1305062065"]A Database Error Occurred


Error Number: 1062

Duplicate entry '' for key 'term'

INSERT INTO okapi_term(idf) VALUES(-2.1972245773362)[/quote]

The error message says it all, in this case. It is telling you that it is trying to insert a blank value for the field term, but there is already a record in the database with a blank term value and it cannot insert this new row as it would be a duplicate (as you must have term marked as unique...).

That's all there is to it...

#5
[eluser]rikes_denis[/eluser]
it turns out that i have indexes the database. i already fix it with delete the index
thanx all for the respons, you'll the best
gbu ^^


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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