Simple mysql table row update
Hi all,
I am new to flex. Literally days into this. I have followed an example from the flex 3 bible and created a Flex applciation calling an AMFPHP service. I got the hello world to appear and was pretty chuffed with that. (code used is below)
I have been asked to use some php code that I used to successfully add a row to my database. Apparently this is easy but I'm not getting it.
All I want to do in this instance is add one row of data to my table. I guess I would just insert my php code in as a statement somewhere right?
The table is on a server
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:RemoteObject id="phpService"
destination="amfphp"
source="MyClass. HelloWorld"/>
<mx:Button label="Say Hello" click="phpService.sayHello()"/>
<mx:Label text="{phpService.sayHello.lastResult}"/>
</mx:Application>
Below: Is this the right bit of code that would update?
var sql:String =
"INSERT INTO mytable (Row1, Row2, Row3 , Row4, Row5, Row6, Row7, Row8, Row9 , Row10) " +
"VALUES ('Data1', 'Data2', 'Data3', 'Data4', 'Data5', 'Data6', 'Data7', 'Data8', 'Data9', 'Data10')";
insertStmt.text = sql;
I really am confused by all this.
Thanks in advance for any help
Hi,
here is a bit of code that may help you, when using amfphp you would have the php class that updates the record, to call that class from flex you would declare it as a remote object. You then send that object with the data to the server where the sql updates the table. The code below is for inserting a record updating a record requires a slightly different sql statement but the principle is pretty much the same.
If you are using flashbuilder you can use zendamf and the data wizard will create your actionscriptcode and your php services code.
David
Actionscript code to update a record through amfphp
<mx:RemoteObject id="catalog" fault="onFault(event)" showBusyCursor="true" source="qiksales" destination="amfphp">
<mx:method name="newCategory" result="isEntered(event)" />
</mx:RemoteObject>
private function AddCategory(e:MouseEvent): void
catalog.newCategory(100,'specials');
Php function
function newCategory($group, $category) {
$mysql = mysql_connect(localhost,"root","");
mysql_select_db( "catalog" );
$Query = "INSERT INTO categorys (groupID, name) VALUES ('$group', '$category')";
$Result = mysql_query( $Query );
return($Result);
Similar Messages
-
Only first row of a mysql table is updated
Hi,
I'm using Netbeans 5.5 with Visual Web Pack and trying to update data, stored in a mysql table.
I use a dropdown list to select a row and show the data in various textfields. This works fine. The problem, that it's not possible to save changes, I enter in the textfields. Everytime only the first row of the table will be (over)written. This happens also with the derby database. I checked the tutorial about inserting, updatting and deleting, it works fine. But they use a table to make changes to the data, so the case is different from mine.
Can anybody give me a hint? I'm going crazy ...
Thanx in advance
Markusyes this sounds crazy. i encountered similar problem with textfields. if they are numerous type, don't forget to add integerConverter to the textfield. it helped me out in my case. hope this helps
dElay -
Table row updated by rowid but not with rownum.
May i know why a table is not getting update when a row specified by rownum
and getting updated when row specified by rowid.
SQL> update emp1 set name='ddd' where rownum = 2;
SQL> /
0 rows updated.
SQL> update emp1 set name='ddd' where rowid='AAJD/dAAPAAASoEAAB';
1 row updated.
Thanks
MaryWhy would it? ROWNUM and ROWID are completely different.
ROWID relates to the physical location of a row on disk.
ROWNUM is a pseudocolumn incremented as rows are RETURNED to the client. Specifying "WHERE ROWNUM = 2" is useless because as each row is examined for suitability, its ROWNUM will be set to 1. This is not equal to 2, so the row is rejected. The next row is then examined, with its ROWNUM of 1, and rejected again. Etc... -
[tools help] what tool can be used for moving file?and table row updating?
I need some help to know which tool can help me in the following task:
#1 Moving of file
situation : After extraction of a file , the file is moved to another directory.
#2 SQL updating
Situation : which tool in mapping can be used to update existing record / perform sql
such as UPDATE SET VALUE TABLE WHERE .... or DELETE...I need some help to know which tool can help me in the following task:
#1 Moving of file
situation : After extraction of a file , the file is moved to another directory.You can move the file using oracle UTL_FILE Package Seach the net with this Key word and create procedure/ function in oracle test it in Database .Once everything is perfect then call the procedure/function form OWB
#2 SQL updating
Situation : which tool in mapping can be used to update existing record / perform sql
such as UPDATE SET VALUE TABLE WHERE .... or DELETE...Set the Load properties of the target table as Update or Delete -
Best way to select several mysql table rows at random?
What is the best and quickest way to have one form button select multiple rows from a table with complete randomness?
Can you also offer some explanation (or link to a good tutorial)- I am a beginner in myql and php.
thanks
p.s. the id column in my table is auto incrementing and has some gaps (due to deletions of records). I do not want any of those gaps to be chosen at random (can they?).What do you have so far? How many rows will your table have and how many do you want to randomize? To produce random result without filter will put a strain on your server, especially if you have a lot of rows and you get a lot of server requests (pageloads). To randomize the results you basically have to recreate the table dynamically then output the result as an array. Again, this will put a huge load on your server. This may sound silly and ridiculously obvious, but have you tried searching the obvious term on google for MySQL random? There are millions of articles that describe the subject. Many first page results will show you exactly what you need to do. Try searching first then if you have trouble ask here, referencing the article you followed by first searching google.
best,
Shocker -
Quikly table row update and freeze ui
Hello forum,
I'm trying update tableview by observablelist with 500 ms frequency. Using this interval the UI freeze.
Can u help me pls?Sorry for late...
this is the code I'm using:
public class AlarmTableFactory {
private final TableView<Alarm> table;
class DataTableCell<T> extends TableCell<Alarm, T> {
@Override
protected void updateItem(T t, boolean empty) {
super.updateItem(t, empty);
if (!empty && getTableRow() != null) {
int row = this.getTableRow().getIndex();
Alarm alarm = getTableView().getItems().get(row);
setStyle(alarm.getlevel().getColor());
setTextFill(alarm.getlevel().getTextFillColor());
setText(String.valueOf(t));
public AlarmTableFactory() {
table = new TableView<Alarm>();
public TableView<Alarm> createTable() {
final Field[] fields = Alarm.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
final int count = i;
final TableColumn<Alarm, String> col = new TableColumn(fields.getName().toUpperCase());
col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Alarm, String>, ObservableValue<String>>() {
private ReadOnlyObjectWrapper ro;
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<Alarm, String> cellDataFeature) {
try {
Alarm alarm = cellDataFeature.getValue();
Method method = alarm.getClass().getMethod("get" + fields[count].getName(), null);
try {
ro = new ReadOnlyObjectWrapper((String) method.invoke(alarm, new Object[0]));
} catch (ClassCastException ex) {
// col.setVisible(false);
catch (IllegalAccessException ex) {
Logger.getLogger(AlarmTableFactory.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(AlarmTableFactory.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(AlarmTableFactory.class.getName()).log(Level.SEVERE, null, ex);
} catch (NoSuchMethodException ex) {
Logger.getLogger(AlarmTableFactory.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(AlarmTableFactory.class.getName()).log(Level.SEVERE, null, ex);
return ro;
col.setCellFactory(new Callback<TableColumn<Alarm, String>, TableCell<Alarm, String>>() {
@Override
public TableCell<Alarm, String> call(TableColumn<Alarm, String> arg0) {
return new DataTableCell();
table.getColumns().add(col);
table.setCache(false);
return table;
And this other code for update table with listenerpublic class AlarmTableController implements MapMarkerAlarmListener {
private final TableView<Alarm> table;
public AlarmTableController(TableView<Alarm> table) {
this.table = table;
@Override
public void mapMarkerAlarmed(ALARM_LEVEL alarmLevel, MapMarker marker) {
final ObservableList<Alarm> row = FXCollections.observableArrayList();
Alarm alarm = new Alarm("", "---", "", "");
row.addAll(alarm);
table.getItems().addAll(row);
alarm = null;
Thanks in advanced,
palban -
Table Row update in Adobe Interactive Form
Hi,
I have a table and i have an input field.When i enter % in input field then i need to write to Javascript so that all the rwos in a particular column should be updated with the input field %.Can anyone solve my problemIssue Resolved by writing Javascript
-
Mysql table rows show as questionmarks
Hi guys,
I'm trying to display the rows of my database table in a datagrid, but as their names are written in bulgarian they appear as questionmarks. Any tips on how I can fix this?
Thanks in advanceI figured it out myself... Just wanted to post the solution if anybody has the same
problem. I had a php script that I used to populate a data grid. Here is the code with the line I had to add to make the table names appear normally:
<?PHP
class PlayersService {
public function getPlayers()
$connection = mysqli_connect("host", "username", "password", "db") or die(mysqli_connect_error());
mysqli_query($connection, "SET CHARACTER SET utf8");
$sql = "SELECT * FROM players";
$result = mysqli_query($connection, $sql) or die("Query failed: " . mysqli_error($connection));
$rows = array();
while ($row = mysqli_fetch_object($result))
$rows[] = $row ;
return $rows;
?> -
Making a jtable auto updates itself from a mysql table
Pretty much what the title says. How can i auto update the jtable for every time my mysql table is updated in anyway? i am implementing this auto update function in my admin program which displays a list of users who are online etc. from the moment a user is offline/online or changes other details displayed in my jtable, i want it to auto update the jtable as soon as the actual mysql table has been updated with new data...
I was thinking of re doing the whole jtable i made and create a thread for that table that has a infinite while loop that keeps repainting the jtable with the new updated data from a mysql table query eg select * from table and store the data into a resultset which then gets transferred into a vector. Load the vector into the jtbale and their ya go�.
what you think of this approach? Is their a better way to do this?
at the moment, as soon as my application opens, the jtable views all the data from my sql table, however if it doesnt auto updates itself, cheersi am implementing this auto update
function in my admin program which displays a list of
users who are online etc. from the moment a user is
offline/online or changes other details displayed in
my jtable, i want it to auto update the jtable as
soon as the actual mysql table has been updated with
new data...Well you can make some changes to make implementation easy
Ex: Create a table to keep a log of the changes in the system the dmin program read the log and replicate the changes as specified in the log on the table model.
When reading the log the admin program keep track of the sequence no of the last read log entry and it reads ony the entries which has larger seq numbers than the last read seq no
I dont think that it is critical to make this to be cloase to real time. An Update once a 1 or 2 secs should be sufficient. -
Exporting a MySQL table to Excel
My users have asked for the ability to download a MySQL table to an Excel spreadsheet. Being an amateur at all this PHP stuff I googled around and found a script that is supposed to do this. It's failing with "Couldn't select database: Access denied for user 'holli10_tonybabb'@'%' to database '_admin' 1044"
It seems to be picking up an extra "@%" from somewhere
I used the same settings that I successfully used for a CRON backup job.. I'd really appreciate any insight you can suggest. The script is shown below,
Thanks
Tony
<?php
//EDIT YOUR MySQL Connection Info:
$DB_Server = "209.200.244.80"; //your MySQL Server
$DB_Username = "holli10_tonybabb"; //your MySQL User Name
$DB_Password = "abcd1234"; //your MySQL Password
$DB_DBName = "_admin"; //your MySQL Database Name
$DB_TBLName = "volunteers"; //your MySQL Table Name
//$DB_TBLName, $DB_DBName, may also be commented out & passed to the browser
//as parameters in a query string, so that this code may be easily reused for
//any MySQL table or any MySQL database on your server
//DEFINE SQL QUERY:
//you can use just about ANY kind of select statement you want -
//edit this to suit your needs!
$sql = "Select * from $DB_TBLName";
//Optional: print out title to top of Excel or Word file with Timestamp
//for when file was generated:
//set $Use_Titel = 1 to generate title, 0 not to use title
$Use_Title = 1;
//define date for title: EDIT this to create the time-format you need
$now_date = date('m-d-Y H:i');
//define title for .doc or .xls file: EDIT this if you want
$title = "Dump For Table $DB_TBLName from Database $DB_DBName on $now_date";
Leave the connection info below as it is:
just edit the above.
(Editing of code past this point recommended only for advanced users.)
//create MySQL connection
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
//select database
$Db = @mysql_select_db($DB_DBName, $Connect)
or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
//execute query
$result = @mysql_query($sql,$Connect)
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
//if this parameter is included ($w=1), file returned will be in word format ('.doc')
//if parameter is not included, file returned will be in excel format ('.xls')
if (isset($w) && ($w==1))
$file_type = "msword";
$file_ending = "doc";
}else {
$file_type = "vnd.ms-excel";
$file_ending = "xls";
//header info for browser: determines file type ('.doc' or '.xls')
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=database_dump.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
/* Start of Formatting for Word or Excel */
if (isset($w) && ($w==1)) //check for $w again
/* FORMATTING FOR WORD DOCUMENTS ('.doc') */
//create title with timestamp:
if ($Use_Title == 1)
echo("$title\n\n");
//define separator (defines columns in excel & tabs in word)
$sep = "\n"; //new line character
while($row = mysql_fetch_row($result))
//set_time_limit(60); // HaRa
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
//define field names
$field_name = mysql_field_name($result,$j);
//will show name of fields
$schema_insert .= "$field_name:\t";
if(!isset($row[$j])) {
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "") {
$schema_insert .= "$row[$j]".$sep;
else {
$schema_insert .= "".$sep;
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
//end of each mysql row
//creates line to separate data from each MySQL table row
print "\n----------------------------------------------------\n";
}else{
/* FORMATTING FOR EXCEL DOCUMENTS ('.xls') */
//create title with timestamp:
if ($Use_Title == 1)
echo("$title\n");
//define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
//start of printing column names as names of MySQL fields
for ($i = 0; $i < mysql_num_fields($result); $i++)
echo mysql_field_name($result,$i) . "\t";
print("\n");
//end of printing column names
//start while loop to get data
while($row = mysql_fetch_row($result))
//set_time_limit(60); // HaRa
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
$schema_insert = str_replace($sep."$", "", $schema_insert);
//following fix suggested by Josue (thanks, Josue!)
//this corrects output in excel when table fields contain \n or \r
//these two characters are now replaced with a space
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
?>
<?php /*_____________________END___OF___THE___CODE______________________
get more code from http://www.fundisom.com/phparadise/
___________________________________________________________________*/ ?>Never mind. The web hosting support people people told me I had my parameters wrong. It works fine now.
-
How to verify that the user has changed table row data before db update
Hi all,
Iam using Oracle ADF with EJBs.
I have a single selection table that displays rows of data returned from a function of my data control.
The columns of my table are editable so that the user can change the data. The user selects a row, changes the data in one or more columns of the row and saves the data by means of a submit button. The code in the submit button, identifies the row of the corresponding iterator that the user clicked on and updates the data in the database (using the 'mergeEntity' function of the EntityManager)
Before saving the data, I want to put some logic to check whether the user has actually changed some data to avoid unnecessary updates in the database . But for this I need a technique to detect that the user has indeed changed some data in the table row.
One technique I have been using so far was to isolate the iterator row of the table and then query the corresponding row in the database table and compare their values.
Except from dummy, this technique is not efficient if the table contains many rows.
Moreover, in my case I have observed that on successive updates on the same row , the query on the database returns the new values (user changed values) and not the actual values contained in the database table. This means that when the user updates an iterator row the cached data affect also the results of the SELECT statement from the actual database table!!! Isn't this strange ?
Can somebody propose me a neat method to detect when the user has changed the the data of an iterator row ?Hey Alan,
The below solution seems overly complicated to me and can not be implemented without a custom screen and/or the use of JavaScript. Also, if your main concern is that a user may accidentally loose all their data because they closed the browser window or the session times out before they hit the save button then this solution does not help you.
There are a couple of simpler approaches you can take here:
# If the use of JavaScript is permissible you can hook into the windows 'onUnload' event, and pop-up a message box which gives the user the opportunity to cancel closing the window and save their case if they haven't already.
# Implement an autosave feature by hooking into one of events provided by web determinations. A simple (but rather naive) way of doing this would be to hook into the OnRenderScreenEvent and call save on the interview session every time the event fires. This guarantees that all the data the user has submitted will aways automatically be saved, thereby removing the need to make sure the user manually saves their data before closing the browser.
Automatically making Web Determinations close a browser window has to be done using JavaScript. However, doing so means that a) it won't work for people who turn off JavaScript, which is commonly done for accessibility reasons b) you'll likely run afoul of the browser's security mechanism (they generally won't let you close a window that you didn't open and some really don't like you doing that at all).
Thanks,
Kristy -
How do I update/insert into a target table, rows after date X
Hi all
I have a mapping from source table A to target table B. Identical table structure.
Target table A updates rows and inserts rows daily. Every week I want to synchronize this with table B.
I have CREATION_DATE and LAST_UPDATE_DATE on both tables. I want to pass in a parameter to this mapping of date X which tells the mapping:
"if CREATION_DATE is past X then do an insert of this row in B, if LAST_UPDATE_DATE is past X then do an update of this row in B"
Please can you help me work out how to map this correctly as I am new to OWB.
Many thanks
AdiHi,
You can achieve this by -
1. Create a control table, say Control_Table, with structure
Map Name, last_load_date. Populate this table with the mappings that synchronizes your Table B.
2. Alter mapping, that loads Table B to use the above control table to get all the records from Table A, you have to join Table A and Control_Table with the condition -
Control_Table.Map_Name = < mapping name>
AND ( TableA.Creation_Date > Control_Table.last_load_date
OR TableA.Last_Update_Date > Control_Table.last_load_date )
3. Then use UPDATE/INSERT on the Table B based on the Keys. This should take care of INSERT ( if not present) / UPDATE (if the row already exists).
4. Schedule the mapping to run on weekly basis.
5. You have to maintain the Control_Table to keep changing the values for Last_Load_Date to pick the data since the last time Table B is synchronized.
HTH
Mahesh -
Multiple row update of a table from another one
Im trying to make a multiple row update with date from a different table, but it's giving me an error.
update inv.mtl_system_items_b
set attribute1 = t2.description,
last_update_date = SYSDATE,
last_updated_by = 3606
from inv.mtl_system_items_b t2
inner join TMP.TMP_INACTIVAR_PRODUCTOS t1
on t2.segment2 = t1.inventory_item_id;Edited by: user8986013 on 21-may-2010 14:15Hi,
Whenever you have a question involving an error message, post the complete error message, including line number. Don't you think that might help people solve your problem?
Whneve you have any question, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. (In the case of a DM<L statement, like UPDATE, the INSERT statements show the tables before the change, and the results are the contents of the changed table after it.)
Review the syntax of the UPDATE statement in the SQL Language manual:
http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10008.htm#sthref9598
MERGE may be more efficient and easier to use than UPDATE. -
Updating table rows in Application Module class
How can I update table rows in Application Module class?
I'm using JDev 10.1.3 ADF BC, not JSF!
Thanks.There are plenty of examples of doing this in the new ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center. No need to use raw JDBC.
http://www.oracle.com/technology/products/adf/learnadf.html
See Chapters 5 and 6 for a start. -
Multiple Row Update From Similar Table
I am attempting to update a table based on similar table if the Entry_Type is D and they have the same log_numbers. I have created queries to show me the results I want but am having some difficulities getting the update to happen. I am getting a single-row subquery returns more than one row error, but I would like to update all necessary rows.
Here is my sql...
UPDATE V.MASTER
SET (MODIFIED_BY, ENTRY_TYPE) = (
SELECT MODIFIED_BY, ENTRY_TYPE
FROM J.BACK)
WHERE LOG_NUMBER IN
(SELECT LOG_NUMBER FROM V.MASTER
WHERE ENTRY_TYPE <> 'D' AND LOG_NUMBER = ANY
(SELECT LOG_NUMBER FROM J.BACK
WHERE ENTRY_TYPE = 'D'))
I would appreciate any assistance! Thanks!You can also use correlated update. This one is from AskTom (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1197999096334)
if you have the proper primary keys to assure uniqueness on S and C, this does it (i have the keys
noted in the creates)
ops$tkyte@ORA920> create table pgp_person
2 ( date_of_birth date,
3 update_by varchar2(10),
4 update_date date,
5 load_timestamp date,
6 person_num int );
Table created.
ops$tkyte@ORA920>
ops$tkyte@ORA920> create table ship_passenger
2 ( date_of_birth date,
3 person_num int,
4 voy_num int,
5 book_num int,
6 seq_num int,
7 primary key (person_num) );
Table created.
ops$tkyte@ORA920>
ops$tkyte@ORA920> create table pgp_cruise_history
2 ( voy_num int,
3 book_num int,
4 seq_num int,
5 matched_ind int,
6 primary key(voy_num,book_num,seq_num) );
Table created.
ops$tkyte@ORA920>
ops$tkyte@ORA920> update ( select p.date_of_birth dob1, s.date_of_birth dob2,
2 p.update_by, p.update_date, p.load_timestamp
3 from pgp_person p, pgp_cruise_history c, ship_passenger s
4 where p.person_num = s.person_num
5 and s.voy_num = c.voy_num
6 and s.book_num = c.book_num
7 and s.seq_num = c.seq_num
8 and c.matched_ind is not null
9 and s.date_of_birth <> p.date_of_birth )
10 set dob1 = dob2,
11 update_by = 'sdm18649',
12 update_date = trunc(sysdate),
13 load_timestamp = sysdate;
0 rows updated.
Maybe you are looking for
-
Importing os Open PO,GRPO and Invoice Through DTW
Hi All, Please tell me what are the exact Templates and Mandatory fields for Open PO,GRPO and Invoice through DTW. Kind Regards silpa
-
Why PC-People don't chose mac, + others.
Let me begin by saying this: I have always been a mac devotee; Extreme! I'm obsessed and practically addicted. I always brag about this system, but I have to say, sometimes - as with every matter/product/etc. - I do think there are things that should
-
I have moved my iPhoto to an external hard drive. so now I have to have the external hard drive connected to my laptop to view the photos. Now when I want to import photos into iPhoto from my media card, I don't have room to connect both devices at
-
Posting a partial payment for customer receipts with full amount
Hi, Is there a way by which I can post the full amount of the invoice as a partial receipt (that is without clearing the open items but at the same time linking the invoice and the amount). If I use F-28 the system clears the line item if the partial
-
Canon Printer Pixma Pro 9000 MKii - OSX 10.9 - photoshop CS5 crashes
I cannot print with my mac OSX 10.9. It is an adobe error with photoshop CS5. Any ideas?