コード例 #1
0
ファイル: SetupDatabase.php プロジェクト: nessi/PartKeepr
	for ($i=0;$i<rand(0,15);$i++) {
		$randomManufacturer = rand(0, count($aManufacturers)-1);
		$oPart->getManufacturers()->add(new PartManufacturer($oPart, $aManufacturers[$randomManufacturer]));
	}
	
	$oPart->getDistributors()->add(new PartDistributor($oPart, $aDistributors[$part["id_supplier"]]));
	
	//echo "Migrating part ".sprintf("%-40s", $part["name"])."\r";
	
	/* Add existing datasheets */
	$datasheetQuery = "SELECT datasheeturl FROM datasheets WHERE part_id = ".$part["id"];
	$r3 = mysql_query($datasheetQuery);
	while ($res = mysql_fetch_assoc($r3)) {
			$attachment = new PartAttachment();
			$attachment->setPart($oPart);
			$attachment->replaceFromURL($res["datasheeturl"]);
			$attachment->setDescription(PartKeepr::i18n("Datasheet"));
			$oPart->getAttachments()->add($attachment);

		
	}
	
	PartKeepr::getEM()->persist($oPart);
	
	$oStock = new StockEntry($oPart, $part["instock"]);
	
	$priceQuery = "SELECT AVG(preis) AS preis FROM preise WHERE part_id = ".$part["id"];
	
	$r2 = mysql_query($priceQuery);
	$res = mysql_fetch_assoc($r2);
	
コード例 #2
0
ファイル: PartTest.php プロジェクト: nessi/PartKeepr
<?php
namespace de\RaumZeitLabor\PartKeepr\Tests;
declare(encoding = 'UTF-8');

include("../src/de/RaumZeitLabor/PartKeepr/PartKeepr.php");

use de\RaumZeitLabor\PartKeepr\Auth\User;
use de\RaumZeitLabor\PartKeepr\Footprint\Footprint;
use de\RaumZeitLabor\PartKeepr\Footprint\FootprintManager;
use de\RaumZeitLabor\PartKeepr\Category\Category;
use de\RaumZeitLabor\PartKeepr\Category\CategoryManager;
use de\RaumZeitLabor\PartKeepr\PartKeepr;
use de\RaumZeitLabor\PartKeepr\Part\Part;
use de\RaumZeitLabor\PartKeepr\Part\PartAttachment;

PartKeepr::initialize();

$test = new PartAttachment();
$test->replaceFromURL("http://www.datasheetcatalog.org/datasheet/motorola/MCT7809BD2T.pdf");