$duplicates = Model_Inventory_Main::find('all', array('where' => array('vin' => $vehicle_data['SERIAL#']))); foreach($duplicates as $dup) { $dup->delete(); }
class Model_Inventory_Main extends \Orm\Model { protected static $_table_name = 'inventory_main'; protected static $_primary_key = array('vehicle_id'); protected static $_properties = array( 'vehicle_id', 'stock_number', 'vin', 'list_price', 'year', 'make', 'model', 'trim', 'type', 'body_style', 'engine', 'transmission', 'ext_colour', 'int_color', 'model_code', 'kilometres', 'created_at', 'updated_at' ); protected static $_many_many = array( 'equipment' => array( 'key_from' => 'vin', 'key_through_from' => 'vehicle_vin', 'table_through' => 'inventory_equipment_association', 'key_through_to' => 'equipment_id', 'model_to' => 'Model_Inventory_Equipment', 'key_to' => 'equipment_id', 'cascade_save' => true, 'cascade_delete' => true, ) ); protected static $_has_many = array( 'standard_equipment' => array( 'key_from' => 'vin', 'model_to' => 'Model_Inventory_Standard_Equipment', 'key_to' => 'vehicle_vin', 'cascade_save' => true, 'cascade_delete' => true, ) ); protected static $_observers = array( 'Orm\Observer_CreatedAt' => array( 'events' => array('before_insert'), 'mysql_timestamp' => false, ), 'Orm\Observer_UpdatedAt' => array( 'events' => array('before_save'), 'mysql_timestamp' => false, ), ); }
Fuel\Core\Database_Exception [ Error ]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.id' in 'where clause' with query: "SELECT `t0`.`vehicle_id` AS `t0_c0`, `t0`.`stock_number` AS `t0_c1`, `t0`.`vin` AS `t0_c2`, `t0`.`list_price` AS `t0_c3`, `t0`.`year` AS `t0_c4`, `t0`.`make` AS `t0_c5`, `t0`.`model` AS `t0_c6`, `t0`.`trim` AS `t0_c7`, `t0`.`type` AS `t0_c8`, `t0`.`body_style` AS `t0_c9`, `t0`.`engine` AS `t0_c10`, `t0`.`transmission` AS `t0_c11`, `t0`.`ext_colour` AS `t0_c12`, `t0`.`int_color` AS `t0_c13`, `t0`.`model_code` AS `t0_c14`, `t0`.`kilometres` AS `t0_c15`, `t0`.`created_at` AS `t0_c16`, `t0`.`updated_at` AS `t0_c17` FROM `inventory_main` AS `t0` WHERE `t0`.`id` IS null LIMIT 1"
It looks like you're new here. If you want to get involved, click one of these buttons!