Home > Archive > PHP DB > February 2007 > Re: [PHP-DB] How to tell if a field type is auto_increment
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DB] How to tell if a field type is auto_increment
|
|
| Niel Archer 2007-01-29, 6:57 pm |
| Hi
Try using:
SHOW COLUMNS FROM db.table LIKE 'field_name%'
and from the returned row, check the 'Extra' column for 'auto_increment'
Niel
| |
| John L. Creed 2007-01-29, 6:57 pm |
| Thanks a Million my Friend. I've been struggling with this for days now
<grin>
--
Regards,
John L. Creed
pcExpressWay Consulting
****************************************
*
dBASE Gold Charter Member 210
****************************************
*
http://www.pcexpressway.com
****************************************
*
"Niel Archer" <niel@catweasel.org> wrote in message
news:20070129224943.FD72.NIEL@catweasel.org...
> Hi
>
> Try using:
> SHOW COLUMNS FROM db.table LIKE 'field_name%'
>
> and from the returned row, check the 'Extra' column for 'auto_increment'
>
> Niel
| |
| John L. Creed 2007-01-30, 6:58 pm |
| Here's what I did wih your help:
function isAutoinc($table,$fieldname){
// returns 0 if false, 1 if true
$breturn = 0;
$sql = "SHOW COLUMNS FROM $table LIKE '$fieldname%' ";
$result = mysql_query($sql) or die("Couldn't open table");
// check column Extra
$row = mysql_fetch_array( $result );
if( $row["Extra"] == "auto_increment" ){
$breturn = 1;
}
mysql_free_result($result);
return $breturn;
}
Thanks again!!!
--
Regards,
John L. Creed
pcExpressWay Consulting
****************************************
*
dBASE Gold Charter Member 210
****************************************
*
http://www.pcexpressway.com
****************************************
*
"Niel Archer" <niel@catweasel.org> wrote in message
news:20070129224943.FD72.NIEL@catweasel.org...
> Hi
>
> Try using:
> SHOW COLUMNS FROM db.table LIKE 'field_name%'
>
> and from the returned row, check the 'Extra' column for 'auto_increment'
>
> Niel
| |
| Niel Archer 2007-01-30, 6:58 pm |
| Hi John,
I'd suggest searching within the Extra field instead of testing for the
value explicitly, as this field can theoretically hold several extra
pieces of information.
Niel
| |
| John L. Creed 2007-02-03, 6:58 pm |
| Ahhh, thanks. I'll do that.
--
Regards,
John L. Creed
pcExpressWay Consulting
****************************************
*
dBASE Gold Charter Member 210
****************************************
*
http://www.pcexpressway.com
****************************************
*
"Niel Archer" <niel@catweasel.org> wrote in message
news:20070130195118.B5A4.NIEL@catweasel.org...
> Hi John,
>
> I'd suggest searching within the Extra field instead of testing for the
> value explicitly, as this field can theoretically hold several extra
> pieces of information.
>
> Niel
|
|
|
|
|