PEAR insert issues

Posted on 2007-10-03
Last Modified: 2013-12-13
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...

Question by:trickyidiot
    LVL 17

    Accepted Solution

    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...
    LVL 6

    Author Comment

    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.
    LVL 6

    Author Comment

    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
    LVL 6

    Author Closing Comment

    I was able to solve this issue and want to close this question so I'm giving you the points

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now