• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • 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...

help?
0
trickyidiot
Asked:
trickyidiot
  • 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...
0
 
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.
0
 
trickyidiotAuthor Commented:
Forget it - I was able to accomplish the same task with a select insert statement

INSERT INTO tbl_project_payout
      (
      partner_original_payout,
      partner_current_payout,
      fine,
      id_project_payment_option,
      id_project_crew_rel,
      created_date,
      modified_date
      )
SELECT
      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,
      sysdate(),
      sysdate()
FROM
      tbl_project p,
      tbl_project_crew_rel pc
WHERE
      pc.id_project = p.id_project
0
 
trickyidiotAuthor Commented:
I was able to solve this issue and want to close this question so I'm giving you the points
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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