X-Git-Url: http://secure.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java index 0815049..fb50a4a 100644 --- a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java +++ b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java @@ -1,5 +1,9 @@ package net.sourceforge.phpdt.sql.wizards; +import net.sourceforge.phpdt.sql.sql.TableRow; +import net.sourceforge.phpdt.sql.view.PHPSourceConsole; +import net.sourceforge.phpdt.sql.view.tableview.TableAdapter; + import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -13,10 +17,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import net.sourceforge.phpdt.sql.sql.MultiSQLServer; -import net.sourceforge.phpdt.sql.sql.TableRow; -import net.sourceforge.phpdt.sql.view.tableview.TableAdapter; - public class PHPDeleteRowPage extends WizardPage implements SQLPage { TableRow row; String[] columnNames; @@ -77,7 +77,12 @@ public class PHPDeleteRowPage extends WizardPage implements SQLPage { GridData fullHorizontal = new GridData(); fullHorizontal.horizontalAlignment = GridData.FILL; values[i].setLayoutData(fullHorizontal); - values[i].setText(data[i]); + + if (data[i] == null || data[i].equals("")) { + values[i].setText('$' + columnNames[i]); + } else { + values[i].setText(data[i]); + } values[i].addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { @@ -111,38 +116,49 @@ public class PHPDeleteRowPage extends WizardPage implements SQLPage { } public void updateQuery() { if (DEBUG) { - System.out.println("Updating query"); + System.out.println("Updating delete query"); } StringBuffer whereClause = new StringBuffer(); int numSelected = 0; + boolean first = false; for (int i = 0; i < columnNames.length; i++) { if (whereValues[i].getSelection()) { numSelected++; + if (first) { + whereClause.append(", "); + } + whereClause.append(columnNames[i]); whereClause.append(" = "); - whereClause.append(values[i].getText()); - whereClause.append(", "); + whereClause.append("'" + values[i].getText() + "'"); + + first = true; } } - if (whereClause.length() > 1) { - whereClause.deleteCharAt(whereClause.length() - 1); - whereClause.deleteCharAt(whereClause.length() - 1); - } - String query = "DELETE FROM " + row.getTable(); + // if (whereClause.length() > 1) { + // whereClause.deleteCharAt(whereClause.length() - 1); + // whereClause.deleteCharAt(whereClause.length() - 1); + // } + String query = "$results = mysql_query(\"DELETE FROM " + row.getTable(); if (numSelected > 0) { - query += " WHERE " + whereClause.toString(); + query += " WHERE " + whereClause.toString() + "\");"; + } else { + query += "\");"; } + if (numSelected > 0) { setMessage(""); } else { setMessage("Warning: no \"where clause\" columns selected, all rows will be deleted"); } + this.getControl().pack(); this.query.setText(query); } public boolean performFinish() { - MultiSQLServer server = MultiSQLServer.getInstance(); - server.execute(query.getText()); + PHPSourceConsole console = PHPSourceConsole.getInstance(); + console.clear(); + console.print(query.getText()); return true; } } \ No newline at end of file