| @@ 837-911 (lines=75) @@ | ||
| 834 | * @throws PropelException |
|
| 835 | * @see doSave() |
|
| 836 | */ |
|
| 837 | protected function doInsert(ConnectionInterface $con) |
|
| 838 | { |
|
| 839 | $modifiedColumns = array(); |
|
| 840 | $index = 0; |
|
| 841 | ||
| 842 | $this->modifiedColumns[PageLinkTableMap::COL_ID] = true; |
|
| 843 | if (null !== $this->id) { |
|
| 844 | throw new PropelException('Cannot insert a value for auto-increment primary key (' . PageLinkTableMap::COL_ID . ')'); |
|
| 845 | } |
|
| 846 | ||
| 847 | // check the columns in natural order for more readable SQL queries |
|
| 848 | if ($this->isColumnModified(PageLinkTableMap::COL_ID)) { |
|
| 849 | $modifiedColumns[':p' . $index++] = 'id'; |
|
| 850 | } |
|
| 851 | if ($this->isColumnModified(PageLinkTableMap::COL_PAGE_ID)) { |
|
| 852 | $modifiedColumns[':p' . $index++] = 'page_id'; |
|
| 853 | } |
|
| 854 | if ($this->isColumnModified(PageLinkTableMap::COL_ACTIVE_FROM)) { |
|
| 855 | $modifiedColumns[':p' . $index++] = 'active_from'; |
|
| 856 | } |
|
| 857 | if ($this->isColumnModified(PageLinkTableMap::COL_ACTIVE_TO)) { |
|
| 858 | $modifiedColumns[':p' . $index++] = 'active_to'; |
|
| 859 | } |
|
| 860 | if ($this->isColumnModified(PageLinkTableMap::COL_SHOW_ON)) { |
|
| 861 | $modifiedColumns[':p' . $index++] = 'show_on'; |
|
| 862 | } |
|
| 863 | if ($this->isColumnModified(PageLinkTableMap::COL_PERMANENT)) { |
|
| 864 | $modifiedColumns[':p' . $index++] = 'permanent'; |
|
| 865 | } |
|
| 866 | ||
| 867 | $sql = sprintf( |
|
| 868 | 'INSERT INTO page_link (%s) VALUES (%s)', |
|
| 869 | implode(', ', $modifiedColumns), |
|
| 870 | implode(', ', array_keys($modifiedColumns)) |
|
| 871 | ); |
|
| 872 | ||
| 873 | try { |
|
| 874 | $stmt = $con->prepare($sql); |
|
| 875 | foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 876 | switch ($columnName) { |
|
| 877 | case 'id': |
|
| 878 | $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
| 879 | break; |
|
| 880 | case 'page_id': |
|
| 881 | $stmt->bindValue($identifier, $this->page_id, PDO::PARAM_INT); |
|
| 882 | break; |
|
| 883 | case 'active_from': |
|
| 884 | $stmt->bindValue($identifier, $this->active_from, PDO::PARAM_INT); |
|
| 885 | break; |
|
| 886 | case 'active_to': |
|
| 887 | $stmt->bindValue($identifier, $this->active_to, PDO::PARAM_INT); |
|
| 888 | break; |
|
| 889 | case 'show_on': |
|
| 890 | $stmt->bindValue($identifier, (int) $this->show_on, PDO::PARAM_INT); |
|
| 891 | break; |
|
| 892 | case 'permanent': |
|
| 893 | $stmt->bindValue($identifier, (int) $this->permanent, PDO::PARAM_INT); |
|
| 894 | break; |
|
| 895 | } |
|
| 896 | } |
|
| 897 | $stmt->execute(); |
|
| 898 | } catch (Exception $e) { |
|
| 899 | Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 900 | throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 901 | } |
|
| 902 | ||
| 903 | try { |
|
| 904 | $pk = $con->lastInsertId(); |
|
| 905 | } catch (Exception $e) { |
|
| 906 | throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
| 907 | } |
|
| 908 | $this->setId($pk); |
|
| 909 | ||
| 910 | $this->setNew(false); |
|
| 911 | } |
|
| 912 | ||
| 913 | /** |
|
| 914 | * Update the row in the database. |
|
| @@ 849-923 (lines=75) @@ | ||
| 846 | * @throws PropelException |
|
| 847 | * @see doSave() |
|
| 848 | */ |
|
| 849 | protected function doInsert(ConnectionInterface $con) |
|
| 850 | { |
|
| 851 | $modifiedColumns = array(); |
|
| 852 | $index = 0; |
|
| 853 | ||
| 854 | $this->modifiedColumns[BannersTableMap::COL_ID] = true; |
|
| 855 | if (null !== $this->id) { |
|
| 856 | throw new PropelException('Cannot insert a value for auto-increment primary key (' . BannersTableMap::COL_ID . ')'); |
|
| 857 | } |
|
| 858 | ||
| 859 | // check the columns in natural order for more readable SQL queries |
|
| 860 | if ($this->isColumnModified(BannersTableMap::COL_ID)) { |
|
| 861 | $modifiedColumns[':p' . $index++] = 'id'; |
|
| 862 | } |
|
| 863 | if ($this->isColumnModified(BannersTableMap::COL_PLACE)) { |
|
| 864 | $modifiedColumns[':p' . $index++] = 'place'; |
|
| 865 | } |
|
| 866 | if ($this->isColumnModified(BannersTableMap::COL_WIDTH)) { |
|
| 867 | $modifiedColumns[':p' . $index++] = 'width'; |
|
| 868 | } |
|
| 869 | if ($this->isColumnModified(BannersTableMap::COL_HEIGHT)) { |
|
| 870 | $modifiedColumns[':p' . $index++] = 'height'; |
|
| 871 | } |
|
| 872 | if ($this->isColumnModified(BannersTableMap::COL_EFFECTS)) { |
|
| 873 | $modifiedColumns[':p' . $index++] = 'effects'; |
|
| 874 | } |
|
| 875 | if ($this->isColumnModified(BannersTableMap::COL_PAGE_TYPE)) { |
|
| 876 | $modifiedColumns[':p' . $index++] = 'page_type'; |
|
| 877 | } |
|
| 878 | ||
| 879 | $sql = sprintf( |
|
| 880 | 'INSERT INTO banners (%s) VALUES (%s)', |
|
| 881 | implode(', ', $modifiedColumns), |
|
| 882 | implode(', ', array_keys($modifiedColumns)) |
|
| 883 | ); |
|
| 884 | ||
| 885 | try { |
|
| 886 | $stmt = $con->prepare($sql); |
|
| 887 | foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 888 | switch ($columnName) { |
|
| 889 | case 'id': |
|
| 890 | $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
| 891 | break; |
|
| 892 | case 'place': |
|
| 893 | $stmt->bindValue($identifier, $this->place, PDO::PARAM_STR); |
|
| 894 | break; |
|
| 895 | case 'width': |
|
| 896 | $stmt->bindValue($identifier, $this->width, PDO::PARAM_INT); |
|
| 897 | break; |
|
| 898 | case 'height': |
|
| 899 | $stmt->bindValue($identifier, $this->height, PDO::PARAM_INT); |
|
| 900 | break; |
|
| 901 | case 'effects': |
|
| 902 | $stmt->bindValue($identifier, $this->effects, PDO::PARAM_STR); |
|
| 903 | break; |
|
| 904 | case 'page_type': |
|
| 905 | $stmt->bindValue($identifier, $this->page_type, PDO::PARAM_STR); |
|
| 906 | break; |
|
| 907 | } |
|
| 908 | } |
|
| 909 | $stmt->execute(); |
|
| 910 | } catch (Exception $e) { |
|
| 911 | Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 912 | throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 913 | } |
|
| 914 | ||
| 915 | try { |
|
| 916 | $pk = $con->lastInsertId(); |
|
| 917 | } catch (Exception $e) { |
|
| 918 | throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
| 919 | } |
|
| 920 | $this->setId($pk); |
|
| 921 | ||
| 922 | $this->setNew(false); |
|
| 923 | } |
|
| 924 | ||
| 925 | /** |
|
| 926 | * Update the row in the database. |
|