| ADOdb Library for PHP Manual | ||
|---|---|---|
| Prev | MetaPrimaryKeys | Next |
Returns an array containing column names that are the primary keys of $table. Supported by mysql, odbc (including db2, odbc_mssql, etc), mssql, postgres, interbase/firebird, oci8 currently.
Views (and some tables) have primary keys, but sometimes this information is not available from the database. You can define a function ADODB_View_PrimaryKeys($databaseType, $database, $view, $owner) that should return an array containing the fields that make up the primary key. If that function exists, it will be called when MetaPrimaryKeys() cannot find a primary key for a table or view.
// In this example: dbtype = 'oci8', $db = 'mydb', $view = 'dataView', $owner = false
function ADODB_View_PrimaryKeys($dbtype,$db,$view,$owner)
{
switch(strtoupper($view)) {
case 'DATAVIEW': return array('DATAID');
default: return false;
}
}
$db = NewADOConnection('oci8');
$db->Connect('localhost','root','','mydb');
$db->MetaPrimaryKeys('dataView');
Returns an associate array of foreign keys, or false if not supported. For example, if table employee has a foreign key where employee.deptkey points to dept_table.deptid, and employee.posn=posn_table.postionid and employee.poscategory=posn_table.category, then $conn->MetaForeignKeys('employee') will return
array(
'dept_table' => array('deptkey=deptid'),
'posn_table' => array('posn=positionid','poscategory=category')
)
The optional schema or owner can be defined in $owner. If $upper is true, then the table names (array keys) are upper-cased.
| Prev | Home | Next |
| MetaColumnNames | Up | ServerInfo |