I am trying to figure out what is causing my PDO Exception.
It's for a custom entity, and I had to rename some table columns because the API data changed (and it was easier to do it this way). It keeps seeming to be saying that something is malformed in my query, but I can't for the life of me figure out what it is - all of the data looks correct, and the entity object right before saving looks entirely normal too.
Here's the exception:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change, changein_percent, volume, average_daily_volume, bid, ask, previous_close' at line 1: INSERT INTO {stockinfo} (symbol, name, last_trade_with_time, last_trade_price_only, last_trade_date, last_trade_time, change__percent_change, change, changein_percent, volume, average_daily_volume, bid, ask, previous_close, open, days_range, year_range, change_from_year_low, percent_change_from_year_low, change_from_year_high, percebt_change_from_year_high, earnings_share, p_e_ratio, short_ratio, dividend_pay_date, ex_dividend_date, dividend_yield, market_capitalization, oneyr_target_price, e_p_s_estimate_current_year, e_p_s_estimate_next_year, e_p_s_estimate_next_quarter, price_e_p_s_estimate_current_year, price_e_p_s_estimate_next_year, p_e_g_ratio, book_value, price_book, price_sales, e_b_i_t_d_a, fiftyday_moving_average, change_from_fiftyday_moving_average, percent_change_from_fiftyday_moving_average, two_hundredday_moving_average, change_from_two_hundredday_moving_average, percent_change_from_two_hundredday_moving_average, stock_exchange, updated) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27, :db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34, :db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39, :db_insert_placeholder_40, :db_insert_placeholder_41, :db_insert_placeholder_42, :db_insert_placeholder_43, :db_insert_placeholder_44, :db_insert_placeholder_45, :db_insert_placeholder_46); Array ( [:db_insert_placeholder_0] => AAPL [:db_insert_placeholder_1] => Apple Inc. [:db_insert_placeholder_2] => 4:00pm - 130.28 [:db_insert_placeholder_3] => 130.28 [:db_insert_placeholder_4] => 5 [:db_insert_placeholder_5] => 4:00pm [:db_insert_placeholder_6] => -1.50 - -1.14% [:db_insert_placeholder_7] => -1.5 [:db_insert_placeholder_8] => -1.14 [:db_insert_placeholder_9] => 50884452 [:db_insert_placeholder_10] => 49022000 [:db_insert_placeholder_11] => 130.51 [:db_insert_placeholder_12] => 130.53 [:db_insert_placeholder_13] => 131.78 [:db_insert_placeholder_14] => 131.25 [:db_insert_placeholder_15] => 129.90 - 131.45 [:db_insert_placeholder_16] => 88.93 - 134.54 [:db_insert_placeholder_17] => 41.35 [:db_insert_placeholder_18] => 46.5 [:db_insert_placeholder_19] => -4.26 [:db_insert_placeholder_20] => -3.17 [:db_insert_placeholder_21] => 8.05 [:db_insert_placeholder_22] => 16.19 [:db_insert_placeholder_23] => 1.3 [:db_insert_placeholder_24] => 5 [:db_insert_placeholder_25] => 5 [:db_insert_placeholder_26] => 1.6 [:db_insert_placeholder_27] => 750.55 [:db_insert_placeholder_28] => 148.75 [:db_insert_placeholder_29] => 9.01 [:db_insert_placeholder_30] => 9.69 [:db_insert_placeholder_31] => 1.83 [:db_insert_placeholder_32] => 14.46 [:db_insert_placeholder_33] => 13.44 [:db_insert_placeholder_34] => 1.11 [:db_insert_placeholder_35] => 22.39 [:db_insert_placeholder_36] => 5.89 [:db_insert_placeholder_37] => 3.58 [:db_insert_placeholder_38] => 72.94B [:db_insert_placeholder_39] => 128.38 [:db_insert_placeholder_40] => 1.9 [:db_insert_placeholder_41] => 1.48 [:db_insert_placeholder_42] => 121.08 [:db_insert_placeholder_43] => 9.2 [:db_insert_placeholder_44] => 7.6 [:db_insert_placeholder_45] => NMS [:db_insert_placeholder_46] => 1433009226 ) in drupal_write_record() (line 7261 of C:\Users\Desktop\Websites\domain\includes\common.inc).
And here's the entity object:
stdClass Object
(
[symbol] => AAPL
[ask] => 130.53
[average_daily_volume] => 49022000
[bid] => 130.51
[book_value] => 22.39
[change__percent_change] => -1.50 - -1.14%
[change] => -1.50
[currency] => USD
[dividend_share] => 2.08
[last_trade_date] => 5/29/2015
[earnings_share] => 8.05
[e_p_s_estimate_current_year] => 9.01
[e_p_s_estimate_next_year] => 9.69
[e_p_s_estimate_next_quarter] => 1.83
[days_low] => 129.90
[days_high] => 131.45
[year_low] => 88.93
[year_high] => 134.54
[market_capitalization] => 750.55B
[e_b_i_t_d_a] => 72.94B
[change_from_year_low] => 41.35
[percent_change_from_year_low] => +46.50%
[change_from_year_high] => -4.26
[percebt_change_from_year_high] => -3.17%
[last_trade_with_time] => 4:00pm - 130.28
[last_trade_price_only] => 130.28
[days_range] => 129.90 - 131.45
[fiftyday_moving_average] => 128.38
[two_hundredday_moving_average] => 121.08
[change_from_two_hundredday_moving_average] => 9.20
[percent_change_from_two_hundredday_moving_average] => +7.60%
[change_from_fiftyday_moving_average] => 1.90
[percent_change_from_fiftyday_moving_average] => +1.48%
[name] => Apple Inc.
[open] => 131.25
[previous_close] => 131.78
[changein_percent] => -1.14%
[price_sales] => 3.58
[price_book] => 5.89
[ex_dividend_date] => 5/7/2015
[p_e_ratio] => 16.19
[dividend_pay_date] => 5/14/2015
[p_e_g_ratio] => 1.11
[price_e_p_s_estimate_current_year] => 14.46
[price_e_p_s_estimate_next_year] => 13.44
[short_ratio] => 1.30
[last_trade_time] => 4:00pm
[oneyr_target_price] => 148.75
[volume] => 50884452
[year_range] => 88.93 - 134.54
[stock_exchange] => NMS
[dividend_yield] => 1.60
[percent_change] => -1.14%
[updated] => 1433009226
)
What precisely am I doing wrong? Could it be that one of my columns has the wrong data type set?
This is with a standard MySQL database.
$entity->save()
?