本文整理汇总了PHP中app\models\Categories::getCategoryID方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::getCategoryID方法的具体用法?PHP Categories::getCategoryID怎么用?PHP Categories::getCategoryID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Categories
的用法示例。
在下文中一共展示了Categories::getCategoryID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseData
/**
* Reads file content and convert into array or object
*
* @params string $filePath
* @return object
*
*/
private function parseData($filePath)
{
$catID = \app\models\Categories::getCategoryID('Construction');
$content = file_get_contents($filePath);
$data = array_map('str_getcsv', file($filePath));
array_walk($data, function (&$a) use($data) {
$a = array_combine($data[0], $a);
});
array_shift($data);
$parsedData = array();
foreach ($data as $key => $item) {
$parsedData[$key] = (object) array();
$parsedData[$key]->date = date("Y-m-d", strtotime($item['date']));
$parsedData[$key]->lot_title = $item['lot title'];
$parsedData[$key]->lot_location = $item['lot location'];
$parsedData[$key]->pre_tax_amount = $item['pre-tax amount'];
$parsedData[$key]->tax_amount = $item['tax amount'];
$parsedData[$key]->category = \app\models\Categories::getCategoryID($item['category']);
$parsedData[$key]->lot_condition = \app\models\LotCondition::getLotConditionID($item['lot condition']);
$parsedData[$key]->tax_name = \app\models\TaxName::getTaxNameID($item['tax name']);
if (is_null($parsedData[$key]->category)) {
// category does not exist, so add it
$parsedData[$key]->category = \app\models\Categories::addCategory($item['category']);
}
if (is_null($parsedData[$key]->lot_condition)) {
// lot condition does not exist, so add it
$parsedData[$key]->lot_condition = \app\models\LotCondition::addLotCondition($item['lot condition']);
}
if (is_null($parsedData[$key]->tax_name)) {
// tax name does not exist, so add it
$parsedData[$key]->tax_name = \app\models\TaxName::addTaxName($item['tax name']);
}
}
return $parsedData;
}