cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

SUMMARY: SQL help: current configuration of BOM

ptc-751978
Newbie

SUMMARY: SQL help: current configuration of BOM

function get_bom_from_intralink($search_for, $bom_level) {
$dbh = odbc_connect("Intralink", "system" , "manager");

$sql = "select pvid.pivid,
pivver as version,
pivrev as revision,
rlname as release
from
pdm.pdm_productitem pid,
pdm.pdm_branch brd,
pdm.pdm_productitemversion pvid,
pdm.pdm_pivrl pivrl
where
pid.piname = '$search_for.asm'
and brd.piid = pid.piid
and pvid.brid = brd.brid
and pivrl.pivid = pvid.pivid
and pivrl.islatest = '1";

$result = odbc_do($dbh, $sql);

if (odbc_num_rows($result)) {
$pivid = 0;

while (odbc_fetch_row($result)) {
if (odbc_result($result, 1) > $pivid) {
$pivid = odbc_result($result, 1);
}
}

$sql = "select dgtopistoredname from pdm.pdm_dependencygraph dg where dg.pivid=$pivid";

$result = odbc_do($dbh, $sql);

while (odbc_fetch_row($result)){
$item = odbc_result($result, 1);
$raw_bom[] = $item;
}

$bom = array_unique($raw_bom); // just get the unique part names

$count = array_count_values($raw_bom); // count how many times each part name occured (this is how the quantity is found, it's not actually stored as a number)

foreach($bom as $item) { // build an array of part number and quantity
$proe_bom[] = array(strtok($item, ".") , $count[$item]);
}

odbc_close($dbh);

return $proe_bom;
} else {
return FALSE;
}
}
Announcements