Hello.
I was wondering if it could be possible to put on the table context menu a "php insert" statement that would put on the clipboard a php insert statement including all the fields (taking into consideration the field type string/numeric/boolean etc)
eg insert into database.table (field1,field2,field3...) VALUES ('',,''...)
or
insert into database.table (field1,field2,field3...) VALUES ($field1,$field2,$field3...)
You could make it more generic like making the menu "php statements" and SELECT,INSERT,DELETE,UPDATE
select select could select everything
eg
SELECT field1,field2,field3 FROM database.table
the DELETE and UPDATE statements could use there primary keys
eg DELETE from database.table WHERE _primarykey_=$key
UPDATE database.table SET field1='$field1',field2='$field2' WHERE _primarykey_=$key
i think it would be a great -easy to develop- feature for all php developers who require to do this several times per day.
Give it a though
Feature Request: php insert and other statements
I meant PHP *SQL* Insert
Something like that. But if the table is new and there are no rows available, you cannot use the Export grid dialog.
The results would be similar with the ones from the export grid dialog, except it would be filled with empty values or php variables
Something like that. But if the table is new and there are no rows available, you cannot use the Export grid dialog.
The results would be similar with the ones from the export grid dialog, except it would be filled with empty values or php variables
Do you mean output like this?
Honestly, it looks like an extremely specific use case to be worth the clutter.
$sql = 'INSERT INTO address (address_id, address, address2, district, city_id, postal_code, phone, last_update) VALUES (?, ?, ?, ?, ?, ?, ?, ?)';
$params = array(
'address_id' => null,
'address' => null,
'address2' => null,
'district' => null,
'city_id' => null,
'postal_code' => null,
'phone' => null,
'last_update' => null,
);
Honestly, it looks like an extremely specific use case to be worth the clutter.
Or something link this
$sql = "INSERT INTO address (address_id, address, address2, district, city_id, postal_code, phone, last_update) VALUES ($address_id, '$address', '$address2', '$district', $city_id, $postal_code, $phone, $last_update)";
I agree, for db admins it's pretty useless. But for web developers saves some valuable time and mental-breakdown for repeating the same procedure (view table properties, check type etc) several times in a project
$sql = "INSERT INTO address (address_id, address, address2, district, city_id, postal_code, phone, last_update) VALUES ($address_id, '$address', '$address2', '$district', $city_id, $postal_code, $phone, $last_update)";
I agree, for db admins it's pretty useless. But for web developers saves some valuable time and mental-breakdown for repeating the same procedure (view table properties, check type etc) several times in a project
I now get you want a one-liner, not an exported set of values already contained in a table. That's what the right-click menu items in the very right query helpers box are for. Expand "Columns in table xy", then select wanted columns and rightclick them, click "Generate INSERT"
Or something link this
$sql = "INSERT INTO address (address_id, address, address2, district, city_id, postal_code, phone, last_update) VALUES ($address_id, '$address', '$address2', '$district', $city_id, $postal_code, $phone, $last_update)";
So you're not interested in the variable definitions, just the SQL? That alright, it could be a useful feature to be able to get these:
INSERT INTO address (address_id, address, address2, district, city_id, postal_code, phone, last_update) VALUES (?, ?, ?, ?, ?, ?, ?, ?);
INSERT INTO address (address_id, address, address2, district, city_id, postal_code, phone, last_update) VALUES (:address_id, :address, :address2, :district, :city_id, :postal_code, :phone, :last_update);
... in addition to what HeidiSQL can already do:
INSERT INTO address
(address_id, address, address2, district, city_id, postal_code, phone, last_update)
VALUES (NULL, '', '', '', 0, '', '', NOW())
Please note that there's nothing PHP specific here, thus it's a great feature.
But the exact feature you suggest is basically only useful to PHP coders who don't want to use prepared statements and I can't help asking: why would anyone not want to use prepared statements?
Please login to leave a reply, or register at first.