• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

PEAR insert issues

PHP5 on Apache2

This is an issue with PEAR, of which I am a n00b.

$dbo2 = DB_DataObject::factory("tbl_project_payout");
      $dbo2->id_project_payment_option = $dbo->id_project_payment_option;
      $dbo2->partner_original_payout = $dbo->original_payout;
      $dbo2->partner_current_payout = $dbo->payout;
      $dbo2->fine = $dbo->fine;
      $dbo2->id_project_crew_rel = $dbo->id_project_crew_rel;
      $dbo2->created_date = '';
      $dbo2->modified_date = '';
      $res = $dbo2->insert();

My issue is with $dbo2->id_project_crew_rel

I have ensured that $dbo2->id_project_crew_rel  has a value, and the field name in the table matches it, but it is not being added into the actual query that is generated:

obj_Tbl_project_payout: CONNECT: Checking for database database_ in options
obj_Tbl_project_payout: databaseStructure: Loaded ini file: /var/www/dev/includes/dbo/db_isp_dev.ini
obj_Tbl_project_payout: QUERY: INSERT INTO tbl_project_payout (id_project_payment_option , partner_original_payout , partner_current_payout , created_date , modified_date ) VALUES ( 2 , '985.01' , '954.47' , NULL , NULL )
obj_Tbl_project_payout: query: QUERY DONE IN 0.0135700702667 seconds
obj_Tbl_project: FETCH: a:5:{s:15:"original_payout";s:6:"655.00";s:6:"payout";s:6:"655.00";s:4:"fine";N;s:25:"id_project_payment_option";s:1:"1";s:19:"id_project_crew_rel";s:3:"115";}

Notice how on that last line, id_project_crew_rel has a value.

This is looping through a few thousand records, all of which have that value, none of which are being populated...

  • 3
1 Solution
Aleksandar BradarićSoftware DeveloperCommented:
take a look at the `INSERT INTO` statement - there's no `id_project_crew_rel` in there at all and that's why you don't see it in the DB...
trickyidiotAuthor Commented:
Yeah - I got that

The issue is with PEAR DB_DataObject

DB_DataObject generates the query based off of the variables passed to it and the fields in the database.

If you look at the code, the variable matching the field name is being defined with a value, but it's not being put into the SQL query that is generated by DB_DataObject

I'l trying to figure out why.
trickyidiotAuthor Commented:
Forget it - I was able to accomplish the same task with a select insert statement

INSERT INTO tbl_project_payout
      p.original_payout as original_payout,
      p.payout as payout,
      p.fine as fine,
      p.id_project_payment_option as id_project_payment_option,
      pc.id_project_crew_rel as id_project_crew_rel,
      tbl_project p,
      tbl_project_crew_rel pc
      pc.id_project = p.id_project
trickyidiotAuthor Commented:
I was able to solve this issue and want to close this question so I'm giving you the points
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now