$offer = new Model_Offer(); $offer->category = new Model_Category(); $offer->save();
Fuel v1.2 Model is extending \Orm\Model in a module
43}); 44 45set_error_handler(function ($severity, $message, $filepath, $line) 46{ 47 load_error_classes(); 48 return \Error::error_handler($severity, $message, $filepath, $line); 49}); 50 51function setup_autoloader() 52{ 53 Autoloader::add_namespace('Fuel\\Core', COREPATH.'classes/');COREPATH/classes/database/connection.php @ line 471
466 return $value->value(); 467 } 468 else 469 { 470 // Convert the object to a string 471 return $this->quote((string) $value); 472 } 473 } 474 elseif (is_array($value)) 475 { 476 return '('.implode(', ', array_map(array($this, __FUNCTION__), $value)).')';COREPATH/classes/database/query/builder/insert.php @ line 168
163 // Use the parameter value 164 $group[$i] = $this->_parameters[$value]; 165 } 166 } 167 168 $groups[] = '('.implode(', ', array_map($quote, $group)).')'; 169 } 170 171 // Add the values 172 $query .= 'VALUES '.implode(', ', $groups); 173 }COREPATH/classes/database/query.php @ line 228
223 // Get the database instance 224 $db = \Database_Connection::instance($db); 225 } 226 227 // Compile the SQL query 228 $sql = $this->compile($db); 229 230 switch(strtoupper(substr($sql, 0, 6))) 231 { 232 case 'SELECT': 233 $this->_type = \DB::SELECT;PKGPATH/orm/classes/query.php @ line 1145
1140 */ 1141 public function insert() 1142 { 1143 $res = \DB::insert(call_user_func($this->model.'::table'), array_keys($this->values)) 1144 ->values(array_values($this->values)) 1145 ->execute($this->connection); 1146 1147 // Failed to save the new record 1148 if ($res[0] === 0) 1149 { 1150 return false;PKGPATH/orm/classes/model.php @ line 1031
1026 $query->set($p, $this->{$p}); 1027 } 1028 } 1029 1030 // Insert! 1031 $id = $query->insert(); 1032 1033 // when there's one PK it might be auto-incremented, get it and set it 1034 if (count($primary_key) == 1 and $id !== false) 1035 { 1036 $pk = reset($primary_key);PKGPATH/orm/classes/model.php @ line 975
970 } 971 } 972 $this->unfreeze(); 973 974 // Insert or update 975 $return = $this->_is_new ? $this->create() : $this->update(); 976 977 $this->freeze(); 978 foreach($this->relations() as $rel_name => $rel) 979 { 980 if (array_key_exists($rel_name, $this->_data_relations))
100 $new_offer->modified_by = '1'; 101 102 // Set the required parameters for Category: 103 $new_offer->category->name = 'On the Fly Category'; 104 105 $new_offer->save(); 106 } 107}
protected static $_has_one = array( 'category' => array( 'key_from' => 'category', 'model_to' => 'Uploader\Model_Category', 'key_to' => 'category_id', 'cascade_save' => true, 'cascade_delete' => false, ) );
protected static $_has_many = array( 'offers' => array( 'key_from' => 'category_id', 'model_to' => 'Uploader\Model_Offer', 'key_to' => 'category', 'cascade_save' => true, 'cascade_delete' => false, ) );
protected static $_properties = array( 'offer_id', 'sku', 'barcode', 'status' );
It looks like you're new here. If you want to get involved, click one of these buttons!