Chris W. Parker wrote:
Hello,
Me again. Excuse for sending two questions so closely together.
I'm looking through the MySQL manual (as well as searching Google and
the PHP site's MySQL functions) trying to find out how to test an Insert
statement (or any other statement for that matter).
Although I haven't found a direct answer, my searching usually points me
to transactions in InnoDB. Is this what I will need to use to do what I
want?
I'm preparing to import a bunch of data that is coming from an Excel
file from one the vendors we deal with and I want to find out what
manual data preparation I need to do. I'm using PHP's
mysql_real_escape_string as well as some other custom functions but I
need to find out if this is enough.
As I imagine it in my head:
TEST INSERT INTO `table` VALUES ('value', 'value');
You can't "test" an insert like this but you could do:
begin;
insert into table values(value1, value2);
rollback;
which does mean you need innodb tables. That will rollback any changes
that the insert does, however I'm not sure what happens to an
auto_increment field in that situation (ie does the value get rolled
back or is it left incremented).
The mysql_query function in php returns a resource or failure, so you
could do:
$result = mysql_query($my_query);
if (!$result) {
echo "Query ${my_query} failed: " . mysql_error() . "<br/>";
} else {
echo "Query ${my_query} worked!<br/>";
}
see php.net/mysql_query for more info.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]