Changeset 107684 in spip-zone
- Timestamp:
- Nov 21, 2017, 8:40:07 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/stocks/trunk/inc/stocks.php
r107673 r107684 34 34 */ 35 35 function set_quantite($objet, $id_objet, $quantite) { 36 37 $table_stocks = table_objet_sql('stocks');38 36 $quantite = intval($quantite); 39 37 40 $insert = sql_insertq( 41 $table_stocks, 42 array( 43 'objet' => $objet, 44 'id_objet' => intval($id_objet), 45 'quantite' => $quantite 46 ) 38 // On cherche l'id_stock de l'objet 39 $id_stock = sql_getfetsel( 40 'id_stock', 41 'spip_stocks', 42 array('objet='.sql_quote($objet), 'id_objet='.intval($id_objet)) 47 43 ); 48 44 49 if (!$insert) { 50 $update = sql_update( 51 $table_stocks, 52 array( 53 'quantite' => intval($quantite) 54 ), 55 array( 56 'objet = '.sql_quote($objet), 57 'id_objet = '.intval($id_objet) 58 ) 59 ); 45 include_spip('action/editer_objet'); 46 if (!$id_stock) { 47 objet_inserer('stock', null, null); 60 48 } 49 $err = objet_modifier('stocks', $id_stock, array('quantite' => $quantite)); 61 50 62 if ($insert || $update) { 63 return $quantite; 64 } else { 65 return false; 66 } 51 return ($err) ? $err : $quantite; 67 52 } 68 53
Note: See TracChangeset
for help on using the changeset viewer.