| @@ 632-671 (lines=40) @@ | ||
| 629 | * @throws PropelException |
|
| 630 | * @see doSave() |
|
| 631 | */ |
|
| 632 | protected function doInsert(ConnectionInterface $con) |
|
| 633 | { |
|
| 634 | $modifiedColumns = array(); |
|
| 635 | $index = 0; |
|
| 636 | ||
| 637 | ||
| 638 | // check the columns in natural order for more readable SQL queries |
|
| 639 | if ($this->isColumnModified(PageLinkProductTableMap::COL_LINK_ID)) { |
|
| 640 | $modifiedColumns[':p' . $index++] = 'link_id'; |
|
| 641 | } |
|
| 642 | if ($this->isColumnModified(PageLinkProductTableMap::COL_PRODUCT_ID)) { |
|
| 643 | $modifiedColumns[':p' . $index++] = 'product_id'; |
|
| 644 | } |
|
| 645 | ||
| 646 | $sql = sprintf( |
|
| 647 | 'INSERT INTO page_link_product (%s) VALUES (%s)', |
|
| 648 | implode(', ', $modifiedColumns), |
|
| 649 | implode(', ', array_keys($modifiedColumns)) |
|
| 650 | ); |
|
| 651 | ||
| 652 | try { |
|
| 653 | $stmt = $con->prepare($sql); |
|
| 654 | foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 655 | switch ($columnName) { |
|
| 656 | case 'link_id': |
|
| 657 | $stmt->bindValue($identifier, $this->link_id, PDO::PARAM_INT); |
|
| 658 | break; |
|
| 659 | case 'product_id': |
|
| 660 | $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); |
|
| 661 | break; |
|
| 662 | } |
|
| 663 | } |
|
| 664 | $stmt->execute(); |
|
| 665 | } catch (Exception $e) { |
|
| 666 | Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 667 | throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 668 | } |
|
| 669 | ||
| 670 | $this->setNew(false); |
|
| 671 | } |
|
| 672 | ||
| 673 | /** |
|
| 674 | * Update the row in the database. |
|
| @@ 632-671 (lines=40) @@ | ||
| 629 | * @throws PropelException |
|
| 630 | * @see doSave() |
|
| 631 | */ |
|
| 632 | protected function doInsert(ConnectionInterface $con) |
|
| 633 | { |
|
| 634 | $modifiedColumns = array(); |
|
| 635 | $index = 0; |
|
| 636 | ||
| 637 | ||
| 638 | // check the columns in natural order for more readable SQL queries |
|
| 639 | if ($this->isColumnModified(PageLinkProductsTableMap::COL_LINK_ID)) { |
|
| 640 | $modifiedColumns[':p' . $index++] = 'link_id'; |
|
| 641 | } |
|
| 642 | if ($this->isColumnModified(PageLinkProductsTableMap::COL_PRODUCT_ID)) { |
|
| 643 | $modifiedColumns[':p' . $index++] = 'product_id'; |
|
| 644 | } |
|
| 645 | ||
| 646 | $sql = sprintf( |
|
| 647 | 'INSERT INTO page_link_products (%s) VALUES (%s)', |
|
| 648 | implode(', ', $modifiedColumns), |
|
| 649 | implode(', ', array_keys($modifiedColumns)) |
|
| 650 | ); |
|
| 651 | ||
| 652 | try { |
|
| 653 | $stmt = $con->prepare($sql); |
|
| 654 | foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 655 | switch ($columnName) { |
|
| 656 | case 'link_id': |
|
| 657 | $stmt->bindValue($identifier, $this->link_id, PDO::PARAM_INT); |
|
| 658 | break; |
|
| 659 | case 'product_id': |
|
| 660 | $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); |
|
| 661 | break; |
|
| 662 | } |
|
| 663 | } |
|
| 664 | $stmt->execute(); |
|
| 665 | } catch (Exception $e) { |
|
| 666 | Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 667 | throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 668 | } |
|
| 669 | ||
| 670 | $this->setNew(false); |
|
| 671 | } |
|
| 672 | ||
| 673 | /** |
|
| 674 | * Update the row in the database. |
|