0

I have am creating a check function that enables me to check that data with the specific id and categoryid is already present in the database:

$fields['Occupation'] = array(3) { [0]=> string(1) "1" [1]=> string(1) "6" [2]=> string(1) "7" }

Line in question:

$occCheck = Jojo::selectQuery("SELECT * FROM {refocus_candidate_category} WHERE canid=? AND categoryid=?", array($emailCheck['id'], $fields['Occupation']));

Why am I getting this Error and how do I resolve:

Unknown column 'Array' in 'where clause'

Full Check Function:

    if($occCheck != FALSE)
    {
        Jojo::updateQuery("UPDATE {refocus_candidate_category} SET canid=?, categoryid=? WHERE canid=? AND categoryid=?", array($emailCheck['id'], $fields['Occupation']));
    }else{
        Jojo::insertQuery("INSERT INTO {refocus_candidate_category} SET canid=?, categoryid=? WHERE canid=? AND categoryid=?", array($emailCheck['id'], $fields['Occupation']));
    }
4

4 に答える 4

1

配列のように見え$fields['Occupation']、 に置き換えられcategoryid=>?< category IDます。カテゴリごとに段階的にデータベースに質問するのはどうですか?

また

$occCheck = Jojo::selectQuery("SELECT * FROM {refocus_candidate_category}
                               WHERE canid=".$emailCheck['id']."
                               AND categoryid in
                                 (".implode(",",$fields['Occupation']).")");

$emailCheck['id']配列でない場合

于 2012-09-20T18:41:02.387 に答える
0

照会する職業を決定する必要があります。

$occCheck = Jojo::selectQuery("
   SELECT * FROM {refocus_candidate_category} WHERE canid=? AND categoryid=?",
   array($emailCheck['id'], $fields['Occupation'][1]));

この場合、インデックス 1 の職業を使用したため、職業 6 が選択されます。

于 2012-09-20T18:42:03.430 に答える
0

Is there a specific reason you're passing an Array to the ...Query( functions rather than separate arguments? PHP is passing the one parameter through to the database - which interprets it as a string - so your query is actually searching for the word "Array" instead.

Try this instead:

$occCheck = Jojo::selectQuery("SELECT * FROM {refocus_candidate_category}".
                              " WHERE canid=? AND categoryid=?",
                              $emailCheck['id'], $fields['Occupation']);
于 2012-09-20T18:40:16.737 に答える
0

It's not exactly clear what you are trying to do in your queries, as you are writing these strange values SET canid=?.

But the problem you are facing is, that you are concatinating entire array in your SQL query string. try to echo an array then you will see it getting printed as Array. That's the source of your problem query gets expanded like someField=Array. Now that Array is not even in single quotes, so mysql is assuming it to be a column. Thus your error.

Remove that array($emailCheck['id'], $fields['Occupation']). And just set $emailCheck['id'], $fields['Occupation'][0]. your field['Occupation'] is and entire array so choose some as per your need.

于 2012-09-20T18:40:50.197 に答える