PDO Primary key of a table Function get primary key of a table using GOModel


Get primary key of a table using PDO

Function Defination

                                void function primaryKey($dbTableName);

Parameters Details

Details Type Example
$dbTableName - table name to be truncated string e.g. "emptable"


                                $GOModel = new GOModel(); //create object of the GOModel class
                                $GOModel->connect("localhost", "root", "", "database");//connect to database
                                /* Get primary key of table function */
                              $primaryKey = $GOModel->primaryKey("wp_posts");         

More Examples

                                //Example 1 
                                $primaryKey = $GOModel->primaryKey("wp_posts");


Return primary key if any else return empty string


Option Details Example
$GOModel->getLastQuery(); Return last query executed SHOW INDEXES FROM `wp_posts` WHERE Key_name = 'PRIMARY'
print_r($GOModel->error) Print errors (if any)