Jump to content
Larry Ullman's Book Forums

mcnally486

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by mcnally486

  1. One more question , i am trying to implement this code in the job controller and i cant get it working , any ideas ?
  2. yup it would appear that adding a Jobnumber field to the customer table will save me a lot of stress, thanks man !!
  3. you the man i think your onto something there !!!
  4. Your nearly there with what i mean, by customer i mean company , and they have many jobs , however they would prefer their job numbers to increment by one each time , for their records it would be job 501, 502, 503, 504 etc. The schema is already there with many jobs contained in the database . The point of the third table is say the company requests a new job , the app looks into the tbl_jobNumber (and the row that has their customer_id) to retrieve unique number for them say 505 which is then inserted into the job_num field of the tbl_jobs table (which contains the details of the job) . the number in the jobnumber table for that company would then be incremented to 506 (which is what would be used for the next job by that customer . see what i mean ? This is how it was done in the VB,net app that existed before this one and i think it is still the best solution
  5. This is where the headache started , i am remaking some software from an existing app/database and one of the requirements is that certain customers wanted job numbers starting from a certain range i.e 500 or if they started at 1 they wouldn't want their next job to be 25 if more jobs had been added to other customers, Its sort of tailoring the job number to the customer , i agree it would be easier to use the job id from the second table as that auto-increments. I am open to ideas of workarounds but i am new to yii and almost all functionality is done except for this and i feel like i have hit a brick wall ! I was thinking about doing a custom SQL query to sort it but am unsure how to do it in yii $model->jobnumber = SELECT JobNo FROM tbl_JobNo where Customer_ID = $model->customer_ID
  6. Sorry i don't think i am explaining this properly or am not understand what you are saying but i appreciate your time i am saving a job record from a form, once this submitted i need to assign a job number to this job record, the job number is not an id it is held in another table the tbl_jobnumber does nothing but hold a number that is used for this purpose , once it is used (assigned to a job record ) it needs to be incremented by one (to be used next time for that customer ) $modelJob->jobnumber = number from tbl_jobnumber that has the same customer_id as the job that has just been created Thanks for helping
  7. Hi and thanks for the response, i understand what you are saying but a value that in i need in the record before save exists in another table related to customers and not jobs . if can work out how to get this value into the record i will be halfway there the value exists in customer(relatedtojobs)->jobno(related to customer) ->jobnumber . Thanks for your help
  8. I have three tables tbl_customer customer_ID(PK) ... .... tbl_job job_ID customer_ID(FK) ... ... tbl_jobNumber ID(PK) jobNumber customer_ID (FK) I am trying to find a solution where if i save a new job, 1. the app will look in tbl_jobNumber for a jobNumber corresponding to the customer_ID of the tbl_job 2. save that as tbl_job.job_ID 3. increment the value in tbl_jobnumber.jobNumber by one (ready for use on the next job) i have tried a few thing including query builder, placing code in beforeSave in the job model .... i have job model with the following relations 'customer' => array(self::BELONGS_TO, 'Customers', 'customer_ID'), and in the customer model the relationships are 'jobs' => array(self::HAS_MANY, 'Jobs', 'customer_ID'), 'jobNos' => array(self::HAS_ONE, 'JobNo', 'Customer_ID'), i would have thought that i could just do $model->job_ID = $model->customer->jobNos->JobNo But that isn't working , can anyone offer any solutions to my problem ?
×
×
  • Create New...