Re: mysql->nextID() problem and patch
| From: | Colin Viebrock | Date: | Fri, 05 Apr 2002 16:34:05 +0000 |
| Subject: | Re: mysql->nextID() problem and patch | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-5201@lists.php.net to get a copy of this message | ||
> I was looking to it and found this other solution:
>
> @@ -565,6 +565,11 @@
> // This should kill all rows except the highest, now we
> // can try again
> $repeat = 1;
> +
> + // If the seq table is empty, force it to have 1
> + } elseif (mysql_affected_rows($this->connection) == 0) {
> + $result = $this->query("REPLACE INTO ${seqname} VALUES
> (1)");
> +
>
> I'll commit my patch if there are no objections with it.
Two comments:
1) we can save some processing and return a "1" after the query, since we
know what the answer is going to be.
2) I think you would still want to lock the table ... at which point your
patch is the same as mine except you use REPLACE instead of INSERT. :)
- Colin