laravel fluent update two tables -



laravel fluent update two tables -

i have 2 tables want update 1 query, cannot find how this?

$update = db::table('users') ->join('addresses', 'users.id', '=', 'addresses.user_id') ->where('id', '=', auth::user()->id) ->update(array( 'firstname' => $userdetails['firstname'], 'lastname' => $userdetails['lastname'], 'email' => $userdetails['email'], 'password' => $userdetails['password'], 'addresses.add_line1' => $userdetails['addl1'], 'addresses.add_line2' => $userdetails['addl2'], 'addresses.town' => $userdetails['town'], 'addresses.county' => $userdetails['county'], 'addresses.post_code' => $userdetails['postcode'] )); dd($update);

but returned

sqlstate[42s22]: column not found: 1054 unknown column 'add_name_no' in 'field list'

anyone got suggestions?

thanks in advance.

i'm afraid there no easy way around other write custom query using db::raw();

even though have added bring together method, laravel not include bring together in query when updating. i'm not 100% sure of reason this, has difference between different database engines.

update

although laravel 4 have feature https://github.com/laravel/framework/commit/57e11e392447206f60d77b33c0646229842315a3

have added laravel application , works treat!

laravel

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -