Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zwracanie zmienionych wierszy
netsprint
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 13.06.2014

Ostrzeżenie: (0%)
-----


Witam, próbuje wyświetlić wiersze, które zostały zmienione podczas użycia funkcji np. update, insert lub delete. Niestety nie wiem jak zwrócić odpowienio zapytanie... wewnątrz else if($check === 0)

  1. ...
  2.  
  3. function execute($execute)
  4. {
  5. function do_alert($msg)
  6. {
  7. echo '<script type="text/javascript">alert("' . $msg . '"); </script>';
  8. }
  9. $execute = strtolower($execute);
  10. $tab = array("update","delete","insert");
  11. foreach( $tab as $tab2) {
  12. $check = strpos($execute, $tab2);
  13. $res;
  14. if($tab2 == "insert" && $check == null){
  15. do_alert('Comand update,delete,insert is on the bad position or you use before comand some white spaces');
  16. //throw new Exception( pg_last_error( $this->connection ) );
  17. return false;
  18. }
  19. else if($tab == "insert" && $check === FALSE && $check !=1)
  20. {
  21. echo $check;
  22. do_alert('Comand update, delete or insert is not found');
  23. //throw new Exception( pg_last_error( $this->connection ) );
  24. return false;
  25.  
  26. }
  27. else if($check === 0)
  28. {
  29. $res=pg_query( $this->connection, $execute );
  30.  
  31. if ( !is_resource( $res ) ) throw new Exception( pg_last_error( $this->connection ) );
  32. echo $res;
  33. return new Resource( $res );
  34.  
  35. // return Resource->fetch();
  36. break;
  37. }
  38.  
  39.  
  40.  
  41. }
  42. }...



  1. class Resource
  2. {
  3. private $resource;
  4.  
  5. function __construct( $res )
  6. {
  7. $this->resource=$res;
  8. }
  9.  
  10. function fetch()
  11. {
  12. return pg_fetch_assoc( $this->resource );
  13. }
  14.  
  15. function __destruct()
  16. {
  17. pg_free_result( $this->resource );
  18. }
  19. }




  1. $db=new Database();
  2. $result=$db->execute( "update użytkownicy SET nick='haker' WHERE nick='maker'" );
  3.  
  4.  
  5.  
  6.  
  7. if ($result) {
  8. while ( $row = $result->fetch())
  9. {
  10. echo "<tr>";
  11. foreach ( $row as $col ) echo "<td>$col</td>";
  12. echo "</tr>";
  13. }
  14. }
  15. $db=null;
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 20.08.2025 - 04:29