How to insert corporate details into database |
Firstly, I dont use a database very much but do find it necessary for storing members info & for logging in.
Now, I want to store corporate info & again for the corporate personnel to log in, just the same as we do in real life. I have a Controller & view that creates folders for each corporation, and later intending the same for each country, and that works good. I just want to store the Corporates Name, Password, and Country into the database, and then be able to log in, just the same as a member logs in. I have created a separate table, tbl_corporates, in the database with 5 columns (1) corporate_id (2) date_ registered (3) corporate_name (4) pass_word (5) country_territory I guess the first 2 can be handled within the database. I have created models for each country, the first being Afghanistancorporate_model. The coding within that model is as follows; PHP Code: <?php Within the Controller I have the following; PHP Code: $this->load->model('Afghanistancorporate_model', 'afghanistancorporate_model'); Ive tried putting the defined variables into the Model but that doesnt work. Ive also tried the $data = array in the Controller but that doesnt work. I have searched many sites to find what Im doing wrong, but to no avail. Can anybody help? PHP Code: $this->Afghanistancorporate_model->insert_corporate($corporatename, $password, $countryterritory); Place that after all your inputs. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-16-2020, 12:39 PM)InsiteFX Wrote: Thanks InsiteFX. To be certain that I understand you correctly, this is what I changed to. PHP Code: public function insert_corporate($corporatename, $password, $countryterritory) But it didnt work. Ive even tried inserting the same data into 3 spare columns I have in the members table but still didnt work. Ive clicked on "create view" in the corporate table and get an error message saying .... "It seems that the connection to the server has been lost" .... But I get the same message if I do the same in the members table. The members table must be connected otherwise it wouldnt log in.
No, you want to do it in the controller.
Controller: PHP Code: $this->load->model('Afghanistancorporate_model', 'afghanistancorporate_model'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-17-2020, 12:05 PM)InsiteFX Wrote: No, you want to do it in the controller. Thanks InsiteFX. I already have the first 4 lines in the Controller. If I put the fifth line in the Controller, after the variable definitions, I get error; Message: Undefined property: Afghanistan::$Afghanistancorporate_model Ive moved it to several different places in the Controller & tried it surrounded by curly brackets but still did not enter the corporate table. The fifth line has been deleted from the model. Im exhausted with ideas, other than trying again to enter it into the members table.
My fault, in your model you gave it an alias name which had a lower case first letter try this now.
PHP Code: $this->load->model('Afghanistancorporate_model', 'afghanistancorporate_model'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-18-2020, 07:48 AM)InsiteFX Wrote: My fault, in your model you gave it an alias name which had a lower case first letter try this now. Yes, that fixed it. But I cant see where I used lower case first letter. The rules are that models must have upper case first letter. Now I know how to insert into a database, I should be able to resolve my other problem of uploading photos & fwrite data for an advert. If I upload the photos first & insert $product into a temp field of a database table then redirect (that Im still working on) to the data upload and recover the $product name by; PHP Code: $product = $this->session->userdata('temp_1'); But then I will need to delete the contents of that field probably best when it redirects to the finished advert. Do you know how to delete the contents? Im jumping the gun here a little coz I should be searching before I ask questions. I hope you dont mind. UPDATE I think I can answer my question as follows. Just correct me if they are wrong. These go into a model; PHP Code: public function insert_product($product) And these go into the appropriate Controllers; PHP Code: $this->members_model->insert_product($product);
You used and alias when you initiated your model.
PHP Code: ---------------------> Model -----------------------> Model Alias Name. You only need the first one the alias is if you want to use a different name for your model. Yes that is the correct way of doing it. On your model calls you can assigning a result from the insert and delete. All the model methods and QueryBuilder return a result from the methods. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-18-2020, 12:30 PM)InsiteFX Wrote: You used and alias when you initiated your model. OK, Im still struggling with the redirect after uploading photos. In the corporate listing, which includes uploading a document, that redirects with no problem, but the photo uploads will not redirect properly. Ive even taken the corporate listing coding and alongside put the photo uploads but still can not find a solution. I put that model coding inside but it didnt work. I'll keep working on it, so maybe back later with other questions.
(11-18-2020, 12:30 PM)InsiteFX Wrote: You used and alias when you initiated your model. Im almost at the my destination. But cant get the $product to enter temp_1 The first line of this coding is in the Controller and other lines in the Model; PHP Code: $this->username_model->update_product($product); If I use "insert" it creates a new line & I dont want that. Im assuming I wont need delete coz a new entry should replace the old. What can be wrong with the above? |
Welcome Guest, Not a member yet? Register Sign In |