{"action":"created","issue":{"url":"https://api.github.com/repos/EchoWine/database/issues/1","labels_url":"https://api.github.com/repos/EchoWine/database/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/EchoWine/database/issues/1/comments","events_url":"https://api.github.com/repos/EchoWine/database/issues/1/events","html_url":"https://github.com/EchoWine/database/issues/1","id":119311886,"number":1,"title":"Migliorare updateMultiple","user":{"login":"EchoWine","id":16058223,"avatar_url":"https://avatars.githubusercontent.com/u/16058223?v=3","gravatar_id":"","url":"https://api.github.com/users/EchoWine","html_url":"https://github.com/EchoWine","followers_url":"https://api.github.com/users/EchoWine/followers","following_url":"https://api.github.com/users/EchoWine/following{/other_user}","gists_url":"https://api.github.com/users/EchoWine/gists{/gist_id}","starred_url":"https://api.github.com/users/EchoWine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EchoWine/subscriptions","organizations_url":"https://api.github.com/users/EchoWine/orgs","repos_url":"https://api.github.com/users/EchoWine/repos","events_url":"https://api.github.com/users/EchoWine/events{/privacy}","received_events_url":"https://api.github.com/users/EchoWine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-28T18:33:38Z","updated_at":"2015-11-30T15:27:52Z","closed_at":null,"body":"Attualmente il metodo updateMultiple funziona in maniera incompleta.\r\nPermette sì un update di una serie di record in base al valore di una colonna, ma solo di una colonna.\r\nE' necessario quindi permettere di aggiornare più colonne, in base a più valori.\r\n\r\nEsempio attuale formato\r\n```php\r\n-> updateMultiple(\r\n    array('name' => 'bonus'),\r\n    array(\r\n        'A' => 1,\r\n        'B' => 2,\r\n        'C' => 3\r\n    )\r\n);\r\n```\r\n\r\nLe valore della colonna bonus viene cambiato in funzione della colonna name.\r\n\r\nUn approccio migliore potrebbe essere questo\r\n```php\r\n-> updateMultiple(\r\n\tarray(\r\n\t\t'name' => 'bonus',\r\n\t\t'surname' => 'malus',\r\n\t),\r\n\tarray(\r\n\t\t[0] => array(\r\n\t\t\t'Mario' => 1,\r\n\t\t\t'Paolo' => 2,\r\n\t\t\t'Luca' => 3\r\n\t\t),\r\n\t\t[1] => array(\r\n\t\t\t'Rossi' => 10,\r\n\t\t\t'Verdi' => 6,\r\n\t\t\t'Bianchi' => 7,\r\n\t\t)\r\n\t),\r\n\tarray(\r\n\t\t'last_update' => 2015\r\n\t)\r\n);\r\n```\r\nOvvero annidando sotto un altro livello il secondo parametro e aggiungendone un terzo per aggiornare tutti gli altri campi, se necessario.\r\n\r\nIn questo esempio coloro che hanno il nome Mario,Paolo e Luca ricevono un bonus corrispondente a 1,2,3; coloro che invece hanno il cognome Rossi,Verdi e Bianchi ricevono un malus corrispondente a 10,6 e 7; qualsiasi record aggiorna il valore della propria colonna last_update a 2015\r\n"},"comment":{"url":"https://api.github.com/repos/EchoWine/database/issues/comments/160661029","html_url":"https://github.com/EchoWine/database/issues/1#issuecomment-160661029","issue_url":"https://api.github.com/repos/EchoWine/database/issues/1","id":160661029,"user":{"login":"EchoWine","id":16058223,"avatar_url":"https://avatars.githubusercontent.com/u/16058223?v=3","gravatar_id":"","url":"https://api.github.com/users/EchoWine","html_url":"https://github.com/EchoWine","followers_url":"https://api.github.com/users/EchoWine/followers","following_url":"https://api.github.com/users/EchoWine/following{/other_user}","gists_url":"https://api.github.com/users/EchoWine/gists{/gist_id}","starred_url":"https://api.github.com/users/EchoWine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EchoWine/subscriptions","organizations_url":"https://api.github.com/users/EchoWine/orgs","repos_url":"https://api.github.com/users/EchoWine/repos","events_url":"https://api.github.com/users/EchoWine/events{/privacy}","received_events_url":"https://api.github.com/users/EchoWine/received_events","type":"User","site_admin":false},"created_at":"2015-11-30T15:27:52Z","updated_at":"2015-11-30T15:27:52Z","body":"Migliorato secondo il seguente esempio:\r\n\r\n```php\r\nDB::table('user') -> updateMultiple(\r\n\tarray(\r\n\t\t0 => array('name','bonus'),\r\n\t\t1 => array('name','malus'),\r\n\t\t2 => 'date'\r\n\t),\r\n\tarray(\r\n\t\t0 => array(\r\n\t\t\t'mario' => 10,\r\n\t\t\t'marco' => 77,\r\n\t\t\t'paolo' => 2,\r\n\t\t\t'luca' => 3\r\n\t\t),\r\n\t\t1 => array(\r\n\t\t\t'mario' => 1,\r\n\t\t\t'paolo' => 2,\r\n\t\t\t'luca' => 3\r\n\t\t),\r\n\t\t2 => 2015\r\n\t)\r\n);\r\n```\r\nIl Bonus e il Malus vengono aggiornati (10,77,2 ecc...) a seconda del nome (mario, marco ecc...). Inoltre viene anche aggiornata la data su tutti i record.\r\n\r\nIl metodo updateMultiple e update risultano praticamente uguali, se non per un'elaborazione dei parametri più complicati. Forse è il caso di unire updateMultiple con update"}}