Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Kohana, ORM, zapis znaków specjalnych
in5ane
post
Post #1





Grupa: Zarejestrowani
Postów: 1 335
Pomógł: 34
Dołączył: 9.11.2005
Skąd: Wrocław

Ostrzeżenie: (10%)
X----


Cześć. Jak w Kohana 3.3 zapisywać poprzez ORM znaki specjalne, jak:
Kod
" ' . - _ ,


Wszystkie te znaki mi wywala i treść po nich.

Ten post edytował in5ane 4.09.2014, 08:18:09
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
in5ane
post
Post #2





Grupa: Zarejestrowani
Postów: 1 335
Pomógł: 34
Dołączył: 9.11.2005
Skąd: Wrocław

Ostrzeżenie: (10%)
X----


Tak wygląda moja metoda:
  1. public function action_settings()
  2. {
  3. $user = Auth::instance()->get_user();
  4.  
  5. if ($_POST)
  6. {
  7. $password = $this->request->post('password');
  8. $password_c = $this->request->post('password_c');
  9. $email = $this->request->post('email');
  10. $company_telephone = $this->request->post('company_telephone');
  11.  
  12. if (!empty($password) && !empty($password_c))
  13. {
  14. if ($password != $password_c)
  15. {
  16. $errors[] = 'Wpisane hasłą różnią się.';
  17. }
  18. }
  19.  
  20. if (empty($email))
  21. {
  22. $errors[] = 'E-mail nie może być pusty.';
  23. }
  24. elseif (!filter_var($email, FILTER_VALIDATE_EMAIL))
  25. {
  26. $errors[] = 'Podany adres e-mail nie jest poprawny.';
  27. }
  28.  
  29. if (empty($company_telephone))
  30. {
  31. $errors[] = 'Telefon nie może być pusty.';
  32. }
  33.  
  34. if (empty($errors))
  35. {
  36. $editUser = ORM::factory('User')->where('id', '=', $user->id)->find();
  37. if (!empty($password) && !empty($password_c))
  38. {
  39. $editUser->password = $password;
  40. }
  41.  
  42. $editUser->email = $email;
  43. $editUser->company_short_name = $this->request->post('company_short_name');
  44. $editUser->company_name = $this->request->post('company_name');
  45. $editUser->company_address = $this->request->post('company_address');
  46. $editUser->company_postcode = $this->request->post('company_postcode');
  47. $editUser->company_city = $this->request->post('company_city');
  48. $editUser->company_nip = $this->request->post('company_nip');
  49. $editUser->company_telephone = $company_telephone;
  50. $editUser->company_fax = $this->request->post('company_fax');
  51. $editUser->save();
  52.  
  53. Flash::success('Dane poprawnie zaktualizowano.');
  54. Request::current()->redirect('account/settings');
  55. }
  56. else
  57. {
  58. foreach ($errors as $error)
  59. {
  60. Flash::warning($error);
  61. }
  62.  
  63. Request::current()->redirect('account/settings');
  64. }
  65. }
  66.  
  67. $this->render();
  68. }
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.11.2025 - 00:58