Welcome Guest, Not a member yet? Register   Sign In
First steps of newbie in CI.
#4

You can not do it like that with QueryBuilder, you need to use the db->query()

With that you can join on two different tables using sql.

You would need two saves one for each id.

You can join on two tables for retrieving the data.

PHP Code:
$db db_connect();

$query $db->query("SELECT * FROM users LIMIT 1;"); 

Use sql to do what you want.

MySQL Tutorial

You can do it with QueryBuilder but you would need to save the first id then switch models.

You did not say if the id's are in different tables but I think they are because your using to models.

Save the first models data then switch tables and save the second models data.

PHP Code:
//$userModel = new \App\Models\UserModel();
save the data

$profileModel 
= new \App\Models\ProfileModel();
//save the data 

That's how you would need to do it with QueryBuilder for getting the data you can use the sql join.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
First steps of newbie in CI. - by jprincon - 10-09-2020, 02:52 PM
RE: First steps of newbie in CI. - by InsiteFX - 10-09-2020, 10:05 PM
RE: First steps of newbie in CI. - by jprincon - 10-11-2020, 01:07 PM
RE: First steps of newbie in CI. - by InsiteFX - 10-11-2020, 05:16 PM
RE: First steps of newbie in CI. - by ojmichael - 10-11-2020, 10:42 PM
RE: First steps of newbie in CI. - by InsiteFX - 10-12-2020, 01:57 AM
RE: First steps of newbie in CI. - by jprincon - 10-12-2020, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB