本文整理汇总了PHP中Items类的典型用法代码示例。如果您正苦于以下问题:PHP Items类的具体用法?PHP Items怎么用?PHP Items使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Items类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertItems
public function insertItems(Items $items)
{
$con = self::openConnection();
$affected = 0;
mysqli_begin_transaction($con);
$stm = mysqli_stmt_init($con);
$sql = "INSERT INTO category VALUES (?, ?, ?)";
mysqli_stmt_prepare($stm, $sql);
foreach ($items->getItems() as $item) {
$code = $item->getCode();
$name = $item->getName();
$parent = $item->getParent() == null ? null : $item->getParent()->getCode();
mysqli_stmt_bind_param($stm, 'sss', $code, $name, $parent);
mysqli_stmt_execute($stm);
if (mysqli_affected_rows($con) == 1) {
$affected++;
}
}
if ($affected > 0) {
mysqli_commit($con);
} else {
mysqli_rollback($con);
}
return $affected;
}
示例2: post_list
function post_list()
{
// only run on the first call
if (!Registry::has('rwar_post_archive')) {
// capture original article if one is set
if ($article = Registry::get('article')) {
Registry::set('original_article', $article);
}
}
if (!($posts = Registry::get('rwar_post_archive'))) {
$posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
Registry::set('rwar_post_archive', $posts = new Items($posts));
}
if ($result = $posts->valid()) {
// register single post
Registry::set('article', $posts->current());
// move to next
$posts->next();
} else {
// back to the start
$posts->rewind();
// reset original article
Registry::set('article', Registry::get('original_article'));
// remove items
Registry::set('rwar_post_archive', false);
}
return $result;
}
示例3: insertItems
public function insertItems(Items $items)
{
$con = self::openConnection();
$affected = 0;
mysqli_begin_transaction($con);
$stm = mysqli_stmt_init($con);
$sql = "INSERT INTO product VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
mysqli_stmt_prepare($stm, $sql);
foreach ($items->getItems() as $item) {
$code = $item->getCode();
$articul = $item->getArticul();
$name = $item->getName();
$bmuID = $item->getBasicMeasurementUnit() == null ? null : $item->getBasicMeasurementUnit()->getId();
$price = $item->getPrice();
$curID = $item->getCurrency() == null ? null : $item->getCurrency()->getId();
$muID = $item->getMeasurementUnit() == null ? null : $item->getMeasurementUnit()->getId();
$parent = $item->getParent() == null ? null : $item->getParent()->getCode();
mysqli_stmt_bind_param($stm, 'sssdddds', $code, $articul, $name, $bmuID, $price, $curID, $muID, $parent);
mysqli_stmt_execute($stm);
if (mysqli_affected_rows($con) == 1) {
$affected++;
}
}
if ($affected > 0) {
mysqli_commit($con);
} else {
mysqli_rollback($con);
}
return $affected;
}
示例4: render
function render()
{
$render = new Render();
$render->assign('update', true);
$render->display('head.tpl');
$items = new Items($this->db);
$list = $items->get_items();
$render->assign('items', $list);
$render->display('items.tpl');
$render->display('foot.tpl');
}
示例5: updateItem
function updateItem($line_of_text)
{
$model = new Items();
$model->item_id = $line_of_text[0];
$model->company_id = $line_of_text[1];
$model->part_number = $line_of_text[2];
if (empty($model->part_number)) {
$model->part_number = 'Not Available';
}
$model->name = $line_of_text[3];
if (empty($model->name)) {
$model->name = 'Not Available';
}
$model->description = $line_of_text[4];
$model->barcode = $line_of_text[5];
$model->location_room = $line_of_text[6];
$model->location_row = $line_of_text[7];
$model->location_column = $line_of_text[8];
$model->location_shelf = $line_of_text[9];
$model->category_id = $line_of_text[10];
$model->current_quantity = $line_of_text[11];
if (empty($model->current_quantity)) {
$model->current_quantity = '0';
}
$model->available_quantity = $line_of_text[12];
if (empty($model->available_quantity)) {
$model->available_quantity = '0';
}
$model->recommended_lowest_quantity = $line_of_text[13];
$model->recommended_highest_quantity = $line_of_text[14];
$model->remarks = $line_of_text[15];
$model->active = $line_of_text[16];
$model->image_url = $line_of_text[17];
$model->sale_price = $line_of_text[18];
$model->factory_due_date = $line_of_text[19];
$model->suppliers_id = $line_of_text[20];
$model->fits_in_model = $line_of_text[21];
$model->created = $line_of_text[22];
$model->modified = $line_of_text[23];
$model->deleted = $line_of_text[24];
if ($model->save()) {
echo '<tr style="background-color:#EAF2D3"><td>' . $model->part_number . '</td><td>Part Number Saved</td><td></td> </tr>';
} else {
$errors = $model->getErrors();
echo '<tr style="background-color:#FF8566"><td>' . $model->part_number . '</td><td>Part Number Not Saved</td><td>';
echo "Item not imported";
foreach ($errors as $e) {
echo "<br>" . $e[0];
}
echo '</td></tr>';
//print_r($model->getErrors()).'</td></tr>';
}
//end of save else
}
示例6: addAction
/**
* The default action - show the home page
*/
public function addAction()
{
$arUser = $this->authenticate();
if (!$this->_request->isPost()) {
$this->view->channel_id = $this->_getParam('channel_id');
$this->view->formAction = $this->getRequest()->getBaseUrl() . '/item/add';
} else {
$channelID = (int) $this->_getParam('channel_id');
$item = new Items();
$item->addItem($channelID, $this->_getParam('title'), $arUser['id']);
$this->_helper->redirector->goto('add', 'item', null, array('channel_id' => $channelID));
}
}
示例7: actionCreate
public function actionCreate()
{
Yii::app()->clientScript->registerPackage('items-edit');
if (!isset($_GET['id']) || NULL == ($model = Items::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'id' => (int) $_GET['id'])))) {
$model = new Items();
}
if (isset($_POST['Items'])) {
$model->attributes = $_POST['Items'];
$fn = Files::model()->uploadFile('Items[image]');
if ($fn) {
$model->image = $fn['filename'];
} elseif (isset($_POST['Items']['image_src'])) {
$model->image = $_POST['Items']['image_src'];
}
$new = $model->isNewRecord;
if ($model->save()) {
$cats = isset($_POST['categories']) ? $_POST['categories'] : array();
if (!$new && empty($cats)) {
ItemsCategory::model()->deleteAllByAttributes(array('item_id' => $model->id));
} else {
if (!$new) {
$dbcats = ItemsCategory::model()->findAll('item_id=:iid', array('iid' => $model->id));
$ids = array();
foreach ($dbcats as $i => $dbc) {
if (false !== ($k = array_search($dbc->category_id, $cats))) {
unset($cats[$k]);
unset($dbc[$i]);
} else {
$ids[] = $dbc->category_id;
}
}
//deleteing corresponding categories
if (!empty($ids)) {
$ids = implode(",", $ids);
ItemsCategory::model()->deleteAll('item_id=:iid AND category_id IN (:cid)', array('iid' => $model->id, 'cid' => $ids));
}
}
if (!empty($cats)) {
foreach ($cats as $cat) {
$c = new ItemsCategory();
$c->attributes = array('category_id' => $cat, 'item_id' => $model->id);
$c->save();
}
}
}
Yii::app()->user->setFlash('ItemSaved', '1');
$this->refresh();
}
}
$this->render('_form', array('model' => $model));
}
示例8: Items
public static function &get_instance()
{
if (!isset(self::$instance)) {
self::$instance = new Items();
}
return self::$instance;
}
示例9: process_single
/**
* Process a single feed
*
* @param array $feed Feed information (required elements are 'name' for error reporting, 'feed' for the feed URL and 'id' for the feed's unique internal ID)
* @return int Number of items added
*/
public static function process_single($feed)
{
do_action('iu-feed-start', $feed);
$sp =& self::load_feed($feed);
if ($error = $sp->error()) {
self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
do_action('iu-feed-finish', $feed);
return -1;
}
$count = 0;
$items = $sp->get_items();
foreach ($items as $item) {
$new_item = self::normalise($item, $feed['id']);
$new_item = apply_filters('item_data_precache', $new_item, $feed);
if (Items::get_instance()->check_item($new_item)) {
$count++;
do_action('iu-item-add', $new_item, $feed);
} else {
do_action('iu-item-noadd', $new_item, $feed);
}
}
$sp->__destruct();
unset($sp);
do_action('iu-feed-finish', $feed);
return $count;
}
示例10: display_page_content
function display_page_content()
{
$section_name = requestIdParam();
$section = Sections::FindByName($section_name);
$item_name = getRequestVarAtIndex(3);
$item = Items::FindByName($item_name);
$gallery = $item->getGallery();
?>
<h1><?php
echo $item->display_name;
?>
</h1>
<?php
$next_item = $item->findNext($section);
$prev_item = $item->findPrev($section);
if ($prev_item) {
echo "\t\t\t\t<a href=\"" . get_link("portfolio/item/{$section_name}/" . $prev_item->name) . "\">previous</a>\n";
}
if ($next_item) {
echo "\t\t\t\t<a href=\"" . get_link("portfolio/item/{$section_name}/" . $next_item->name) . "\">next</a>\n";
}
echo $item->content;
foreach ($gallery->get_photos() as $photo) {
echo "<img src=\"/" . $photo->getPublicUrl() . "\" /><br />";
}
}
示例11: process
public static function process()
{
header('Content-Type: text/plain; charset=utf-8');
require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
$updated = false;
foreach (self::$feeds as $feed) {
do_action('iu-feed-start', $feed);
$sp = self::load_feed($feed);
if ($error = $sp->error()) {
self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
continue;
}
$count = 0;
$items = $sp->get_items();
foreach ($items as $item) {
$new_item = self::normalise($item, $feed['id']);
$new_item = apply_filters('item_data_precache', $new_item);
if (Items::get_instance()->check_item($new_item)) {
$count++;
$updated = true;
}
}
do_action('iu-feed-finish', $feed);
}
Items::get_instance()->sort_all();
if ($updated) {
Items::get_instance()->save_cache();
}
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($main_item_id)
{
$model = new OutboundItemsHistory();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$model->main_item_id = $main_item_id;
if (isset($_POST['OutboundItemsHistory'])) {
$model->attributes = $_POST['OutboundItemsHistory'];
if ($model->save()) {
$available_quantity = $model->available_quantity_in_stock - $model->quantity_moved;
$current_quantity = $model->current_quantity_in_stock - $model->quantity_moved;
//$q_moved=$model->quantity_moved;
$itemModel = Items::model()->updateByPk($model->main_item_id, array('available_quantity' => $available_quantity + $model->quantity_moved, 'current_quantity' => $current_quantity + $model->quantity_moved));
//if($model->save())
$this->redirect(array('view', 'id' => $model->history_id_item));
}
}
$this->render('create', array('model' => $model));
/*original
if(isset($_POST['OutboundItemsHistory']))
{
$model->attributes=$_POST['OutboundItemsHistory'];
if($model->save())
$this->redirect(array('view','id'=>$model->history_id_item));
}
$this->render('create',array(
'model'=>$model,
));*/
}
示例13: getByOwner
public function getByOwner($ownerID)
{
$DBH = utility::connectToDB();
if ($DBH == \NULL) {
return \NULL;
}
$sql = "\n\t\t\t\t SELECT \n\t\t\t\t\t * \n\t\t\t\t FROM \n\t\t\t\t items\n\t\t\t\t WHERE \n\t\t\t\t\t owner = :id\n\t\t\t\t ";
try {
$STH = $DBH->prepare($sql);
$STH->bindParam(':id', $ownerID);
if ($STH->execute()) {
$results = $STH->fetchAll();
} else {
echo 'Error: retreaving data\\n';
print_r($DBH->errorInfo());
print_r($STH->errorInfo());
return \NULL;
}
$count = $STH->rowCount();
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
$DBH = \NULL;
return \NULL;
}
$DBH = \NULL;
return Items::newCollection($results, $count);
}
示例14: instapaper_submit
function instapaper_submit()
{
$id = $_GET['id'];
$item = Items::get_instance()->get_item($id);
if (false === $item) {
throw new Exception(_r('Invalid item ID specified', 'instapaper'));
}
$user = get_option('instapaper_user');
if (empty($user)) {
throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
}
if (!check_nonce($_GET['_nonce'])) {
throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
}
$data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
$request = new HTTPRequest('', 2);
$response = $request->post("https://www.instapaper.com/api/add", array(), $data);
switch ($response->status_code) {
case 400:
throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
case 403:
throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
case 500:
throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
}
instapaper_page_head();
?>
<div id="message">
<h1><?php
_e('Success!');
?>
</h1>
<p class="sidenote"><?php
_e('Closing window in...', 'instapaper');
?>
</p>
<p class="sidenote" id="counter">3</p>
</div>
<script>
$(document).ready(function () {
setInterval(countdown, 1000);
});
function countdown() {
if(timer > 0) {
$('#counter').text(timer);
timer--;
}
else {
self.close();
}
}
var timer = 2;
</script>
<?php
instapaper_page_foot();
die;
}
示例15: items_getList
public static function items_getList($start = 0, $limit = null)
{
$items = Items::get_instance()->retrieve();
if ($limit == null) {
return $items;
}
return array_slice($items, $start, $limit, true);
}