framework/db/schema/pgsql/CPgsqlSchema.php
protected function findPrimaryKey($table,$indices)
	{
		$indices=implode(', ',preg_split('/\s+/',$indices));
		$sql=<<<EOD
SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
	attrelid=(
		SELECT oid FROM pg_catalog.pg_class WHERE relname=:table AND relnamespace=(
			SELECT oid FROM pg_catalog.pg_namespace WHERE nspname=:schema
		)
	)
	AND attnum IN ({$indices})
EOD;
		$command=$this->getDbConnection()->createCommand($sql);
		$command->bindValue(':table',$table->name);
		$command->bindValue(':schema',$table->schemaName);
		foreach($command->queryAll() as $row)
		{
			$name=$row['attname'];
			if(isset($table->columns[$name]))
			{
				$table->columns[$name]->isPrimaryKey=true;
				if($table->primaryKey===null)
					$table->primaryKey=$name;
				elseif(is_string($table->primaryKey))
					$table->primaryKey=array($table->primaryKey,$name);
				else
					$table->primaryKey[]=$name;
			}
		}
	}
protected function findPrimaryKey($table,$indices)
	{
		$indices=implode(', ',preg_split('/\s+/',$indices));
		$sql=<<<EOD
SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
	attrelid=(
		SELECT oid FROM pg_catalog.pg_class WHERE relname=:table AND relnamespace=(
			SELECT oid FROM pg_catalog.pg_namespace WHERE nspname=:schema
		)
	)
	AND attnum IN ({$indices})
EOD;
		$command=$this->getDbConnection()->createCommand($sql);
		$command->bindValue(':table',$table->name);
		$command->bindValue(':schema',$table->schemaName);
		foreach($command->queryAll() as $row)
		{
			$name=$row['attname'];
			if(isset($table->columns[$name]))
			{
				$table->columns[$name]->isPrimaryKey=true;
				if($table->primaryKey===null)
					$table->primaryKey=$name;
				elseif(is_string($table->primaryKey))
					$table->primaryKey=array($table->primaryKey,$name);
				else
					$table->primaryKey[]=$name;
			}
		}
	}
protected function findPrimaryKey ( $ table , $ indices ) { $ indices = implode ( ', ' , preg_split ( '/\s+/' , $ indices ) ) ; $ sql = <<<EOD
SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
	attrelid=(
		SELECT oid FROM pg_catalog.pg_class WHERE relname=:table AND relnamespace=(
			SELECT oid FROM pg_catalog.pg_namespace WHERE nspname=:schema
		)
	)
	AND attnum IN ({$indices})
EOD ; $ command = $ this -> getDbConnection ( ) -> createCommand ( $ sql ) ; $ command -> bindValue ( ':table' , $ table -> name ) ; $ command -> bindValue ( ':schema' , $ table -> schemaName ) ; foreach ( $ command -> queryAll ( ) as $ row ) { $ name = $ row [ 'attname' ] ; if ( isset ( $ table -> columns [ $ name ] ) ) { $ table -> columns [ $ name ] -> isPrimaryKey = true ; if ( $ table -> primaryKey === null ) $ table -> primaryKey = $ name ; elseif ( is_string ( $ table -> primaryKey ) ) $ table -> primaryKey = array ( $ table -> primaryKey , $ name ) ; else $ table -> primaryKey [ ] = $ name ; } } }
Collects primary key information.
@param CPgsqlTableSchema $table the table metadata
@param string $indices pgsql primary key index list
Collects primary key information .