2012-03-07 8 views
0

CI 2.1.0で作業中で、非オブジェクト上のメンバ関数set()への呼び出しエラーが発生しました。以下の配列を抜粋してコードを抜粋してください。一見、それはすべての文字列の配列なので、私はなぜそれが途中で失敗するように見えるのか困っています。配列を介してループしているオブジェクト以外のエラーでメンバ関数set()を呼び出す

何が起こっているかについての洞察はすばらしいでしょう。このエラーに関するその他の質問を調査しましたが、依然として紛失しています。

Code excerpt: 
foreach($data['jobs'] as $job) 
{ 
foreach($job as $key=>$value){ 
    $job->set($key,$value); 

} 

} 

$データ[ '仕事']配列:

Array ([0] => Array ([job_id] => 149 [company] => Minnesota Life Insurance [location] => Barrington, IL [start_date] => March '98 [end_date] => June '98 [description] => 
Primary responsibility was research and design of sales and training presentations. 
Responsible for scheduling a three person sales and training staff. 
[title] => Administrative Secretary [resume_id] => 96 [order_id] => 0 [profile_id] => 38 [user_id] => 1 [vanity_name] => Sample of Template 3 [template_id] => 3 [date_add] => 0000-00-00 00:00:00 [date_mod] => 2012-03-04 11:00:05) [1] => Array ([job_id] => 150 [company] => Manpower Temporary Services [location] => Naperville, IL [start_date] => Dec' 04 [end_date] => June '98 [description] => 
Assigned to GE Silicones in the industrial sales division. 
Responsible for analysis of monthly, weekly, and, daily sales reports. 
Responsible for scheduling training classes, seminars, and conferences 
[title] => Independent Contractor [resume_id] => 96 [order_id] => 1 [profile_id] => 38 [user_id] => 1 [vanity_name] => Sample of Template 3 [template_id] => 3 [date_add] => 0000-00-00 00:00:00 [date_mod] => 2012-03-04 11:00:05) [2] => Array ([job_id] => 151 [company] => KSMR Radio 92.5/94.3FM [location] => Winona, MN [start_date] => May '96 [end_date] => May '97 [description] => 
In charge of a 36 member staff, as well as a 7 member management team, with duties that include disciplinary actions, budgeting, special requests, program scheduling, and hiring. 
Balancing a $15,000 dollar budget, as well as chairing a committee to receive a grant for increasing station amenities such as wattage, equipment, space, and music library. 
[title] => General Manager [resume_id] => 96 [order_id] => 2 [profile_id] => 38 [user_id] => 1 [vanity_name] => Sample of Template 3 [template_id] => 3 [date_add] => 0000-00-00 00:00:00 [date_mod] => 2012-03-04 11:00:05)) 

答えて

1

$ジョブはクラスではないので、それはあなたが上メンバ関数セットに」()の呼び出しを取得する理由thatsの、です非オブジェクト ' - $ jobは配列です。あなたは次のようにそれにアクセスしなければなりません。

$job['job_id'] = 149; 
$job['company'] = 'Minnesota Life Insurance'; 

$ jobの値をクラスに転送したいのですか?

+0

ありがとうございます - 私は私が続くと信じています。 $ data ['resume']のようなシンプルな配列を使用してforeachを使って渡すと、まだうまくいきません。 – jsuissa

+0

@jsuissa $ data ['resume']の要素はクラスそのものですが、$ data ['jobs']の要素は単純な型に過ぎません。 – DdD

+0

$ job->は$ jobs->だったはずです。どうも!一度それはクラスではないと言っただけで、それはタイプミスである必要がありますクリックした。 – jsuissa

関連する問題