[English version available further below] Démonstration Time Entry Application pour PHP avec MySQL ======================================================== par PhilFlash http://philflash.inway.fr Macromedia a publié une démonstration Time Entry qui permet de lire et d'écrire dans une base de données mais surtout d'analyser les résulats d'un updatePacket pour remettre à jour l'application Flash en cas d'erreur. Cette démonstration utilise ColdFusion MX et est disponible à l'adresse suivante : http://www.macromedia.com/devnet/mx/flash/articles/time_entry.html Voici cette démonstration en PHP avec une base de données MySQL. Pre-requis =========== - serveur IIS ou Apache - base de données MySQL - phpMyAdmin version 2.5.4 : http://www.phpmyadmin.net - PHP version 5.0.0 beta2 ou supérieure : http://www.php.net/downloads.php Installation ============ Vous devez configurer Apache (ou IIS) pour pouvoir utiliser PHP version 5 et MySQL. Installation ------------ - Dézipper le tout dans un répertoire - Copier le répertoire server\time_entry_php dans un répertoire de Apache (ou IIS) => vous devez avoir accès au répertoire suivant : time_entry_php Création de la base et des tables --------------------------------- - créer une base avec phpMyAdmin - modifier le fichier initdb.php en remplacant myhostname myusername mypassword mydatabase avec vos identifiants. - lancer le fichier initdb.php pour créer les tables et les données http://localhost/time_entry_php/initdb.php - vérifier que la table "TimeEntry" a bien été créée avec phpMyAdmin - modifier le fichier connectdb.php en remplacant myhostname myusername mypassword mydatabase avec vos identifiants. - lancer l'application Lancement de l'application ========================== - Lancer un navigateur et entrer comme URL: http://localhost/time_entry_php/TimeEntry.html - Cliquer sur Load pour charger les enregistrements de la base - Vous pouvez créer, modifier ou supprimer des enregistrements. Cliquer sur Save pour sauver vos modifications Cliquez sur Load pour recharger la base - Pour créer des erreurs et visualiser les undo . Créer, modifier ou supprimer des enregistrements. . Cliquer sur "Save With Error" pour sauver vos modifications . Une fenêtre "Reconcile Dialog" apparait. . Pour annuler une modification, cochez l'option "Discard this change" Liste des modifications apportées ================================= - on utilise le format de date ISO YYYY-MM-DD pour être compatible MySQL (mais aussi pour Access et SQL-Server) et être indépendant du pays et du format de date de la machine - on a ajouté un bouton "Save With Error" pour générer des erreurs (méthode rdbmsTimeEntryBeforeApplyUpdatesHandler de TimeEntryData.as) => pour les opérations de type update et insert, on modifie le nom des champs en les préfixant par "BUG_" => pour les opérations de type delete, on modifie le nom de l'ID en le préfixant par "BUG_" - dans l'écran "dmTimeEntry", on a modifié les composants WebServiceConnector en composant XmlConnector - Seuls deux fichiers ont été modifiés : TimeEntry.as et TimeEntryData.as Les lignes qui ont été modifiées sont préfixées par : // PhilFlash Bons tests... PhilFlash http://philflash.inway.fr philflash@inway.fr ===================================================================== ===================================================================== Time Entry Application in PHP with MySQL ======================================== by PhilFlash http://philflash.inway.fr Macromedia has published the Time Entry sample application which makes reading and writing into a database possible but also allows analyzing the result of an updatePacket in order to refresh the flash application in case of error. This demonstration uses ColdFusion MX and is available at the following url: http://www.macromedia.com/devnet/mx/flash/articles/time_entry.html Here is this demonstration in PHP with a MySQL database. Requirements ============ - Web server (Apache or IIS) - MySQL database: http://www.mysql.com/ - phpMyAdmin version 2.5.x or higher: http://www.phpmyadmin.net - PHP version 5.0.0 beta2 or higher: http://www.php.net/downloads.php Installation ============ You must configure Apache (or IIS) to use PHP version 5 and MySQL. Installation ------------ - Unzip the whole package into a separate directory - Copy the directory server\time_entry_php in an Apache (or IIS) directory => you must have access to the following directory: time_entry_php Creation of the database, the table structure and the data ---------------------------------------------------------- - Create a database with phpMyAdmin - Modify the file 'initdb.php' and replace the following variables to reflect your configuration: myhostname myusername mypassword mydatabase - Execute the file initdb.php to create the table structure and the data http://localhost/time_entry_php/initdb.php - Check that the table "TimeEntry" was actually created with phpMyAdmin - Modify the file 'connectdb.php' and replace the following variables to reflect your configuration: myusername mypassword mydatabase with your identifiers. - Run the application Running the demonstration ========================= - Start a browser and enter the following URL: http://localhost/time_entry_php/TimeEntry.html - Click on the Load button to load the database - You can create, modify or remove records. Click on Save to save your modifications. Click on Load to reload the database - To create errors and to visualize the undo. . Create, modify or remove records. . Click on "Save With Error" to save your modifications. A window "Reconcile Dialog" appears. To undo a modification, select the option "Discard this change". List of modifications ===================== - Use the ISO data format (YYYY-MM-DD) to be compatible with MySQL (but also with Access and SQL-Server) and to be independent of the country and date format of the computer. - Add a "Save With Error" button to generate errors. (method rdbmsTimeEntryBeforeApplyUpdatesHandler of TimeEntryData.as) . For the update and insert operations, add the prefix "BUG _" to the name of the fields . For the delete operations, add the prefix "BUG _" to the name of the ID - in the screen "dmTimeEntry", replace WebServiceConnector components by XmlConnector components - Only two files were modified: TimeEntry.as and TimeEntryData.as. The lines which were modified are prefixed by: //PhilFlash Good tests... PhilFlash http://philflash.inway.fr philflash@inway.fr