当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::getAll方法代码示例

本文整理汇总了PHP中Collection::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getAll方法的具体用法?PHP Collection::getAll怎么用?PHP Collection::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection::getAll方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find

 static function find($found_id)
 {
     $found_collection = null;
     $collections = Collection::getAll();
     foreach ($collections as $collection) {
         $id = $collection->getId();
         if ($id == $found_id) {
             $found_collection = $collection;
         }
     }
     return $found_collection;
 }
开发者ID:Camolot,项目名称:inventory-PHP-databases,代码行数:12,代码来源:collection.php

示例2: test_deleteAll

 function test_deleteAll()
 {
     //Arrange
     $name = "Hello Kitty";
     $name2 = "Pokemon";
     $test_collection = new Collection($name);
     $test_collection->save();
     $test_collection2 = new Collection($name2);
     $test_collection2->save();
     //Act
     Collection::deleteAll();
     $result = Collection::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
开发者ID:Camolot,项目名称:inventory-PHP-databases,代码行数:15,代码来源:collectionTest.php

示例3: test_deleteAll

 function test_deleteAll()
 {
     //Arrange
     $thing = "Run the World";
     $thing2 = "20 20 Experience";
     $test_collection = new Collection($thing);
     $test_collection->save();
     $test_collection2 = new Collection($thing2);
     $test_collection2->save();
     //Act
     Collection::deleteAll();
     //Assert
     $result = Collection::getAll();
     $this->assertEquals([], $result);
 }
开发者ID:jmalo34,项目名称:Inventory_Collection,代码行数:15,代码来源:CollectionTest.php

示例4: json_encode

<?php

include_once 'collection.php';
$Collection = new Collection();
$jsondata = array();
if (isset($_GET['all'])) {
    $jsondata = $Collection->getAll();
    for ($x = 0; $x < count($jsondata); $x++) {
        $id = $jsondata[$x][0];
        $num = $Collection->getCountSnippetsById($id);
        //array_push($jsondata[$x],$num[0][0]);
        $jsondata[$x]['num_snippets'] = $num[0][0];
    }
    //$jsondata = $Collection->getCountSnippetsById(1);
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($jsondata);
//echo $jsondata[1][2];
exit;
开发者ID:pablocazorla,项目名称:Snippets,代码行数:19,代码来源:get.php

示例5: LoadByCritere

 public function LoadByCritere($critere, $debutliste = null, $nbenr = null, $tri = 0, $sens = 'ASC')
 {
     $db = Database::getInstance();
     //var_dump($db);
     $tablename = $this->_tablename;
     $classe = $this->_classename;
     $req = "SELECT * FROM {$tablename} WHERE {$critere}";
     $tri++;
     $req .= " ORDER BY {$tri} {$sens}";
     //gestion de la limite
     if (!is_null($debutliste) && !is_null($nbenr)) {
         $req .= " LIMIT {$debutliste},{$nbenr}";
     }
     //var_dump($req);
     $stmt = $db->prepare($req);
     $stmt->execute();
     $lesobjets = new Collection();
     /*
      * Pour chaque ligne du jeu d'enregistrement
      */
     while ($jeuenregistrement = $stmt->fetch(PDO::FETCH_ASSOC)) {
         /*
          * Creation d'une collection de valeurs de champ
          */
         $params = new Collection();
         /*
          * Pour chacune des colonnes de la ligne en cours
          */
         foreach ($jeuenregistrement as $champ => $valeur) {
             //On stocke la valeur dans la collection
             $params->add($valeur);
         }
         $dataligne = $params->getAll();
         //var_dump($dataligne);
         /*
          * On instancie un objet avec toute les valeurs de ces colonnes (dans le tableau de valeur)
          */
         $monobjet = new $classe($dataligne);
         /*
          * On ajoute l'objet a la collection
          */
         $lesobjets->add($monobjet);
     }
     /*
      * Retour de la collection
      */
     return $lesobjets;
 }
开发者ID:Fulbert28,项目名称:PedaFramework,代码行数:48,代码来源:Entity.class.php

示例6: PDO

Debug::enable();
$app = new Silex\Application();
// Set Silex debug mode in $app object
$app['debug'] = true;
$server = 'mysql:host=localhost;dbname=inventory';
$username = 'root';
$password = 'root';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get('/', function () use($app) {
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/collection', function () use($app) {
    $collection = new Collection($_POST['name']);
    $collection->save();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/delete_collections', function () use($app) {
    Collection::deleteAll();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/item', function () use($app) {
    $item = new Item($_POST['name']);
    $item->save();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/delete_items', function () use($app) {
    Item::deleteAll();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
return $app;
开发者ID:Camolot,项目名称:inventory-PHP-databases,代码行数:31,代码来源:app.php

示例7: index

 public function index()
 {
     $this->layout->title = 'Collection';
     $this->layout->pageBar = false;
     $this->layout->content = View::make('admin.collections-all')->with(['collections' => Collection::getAll(), 'types' => Type::getSource(false), 'categories' => Category::getSource(false), 'maxHeight' => 500]);
 }
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:6,代码来源:CollectionsController.php

示例8: Patch

<?php

include "../patches.php";
$patch = new Patch(14);
if (!$patch->exists()) {
    $sql = "CREATE TABLE IF NOT EXISTS `bot_queues` (\n\t\t        `queue_id` INT(11) UNSIGNED NOT NULL,\n\t\t        `bot_id` INT(11) UNSIGNED NOT NULL,\n\t\t        `priority` INT(11) UNSIGNED NOT NULL,\n\t\t        PRIMARY KEY (`queue_id`, `bot_id`, `priority`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8";
    db()->execute($sql);
    $sql = "SELECT id, queue_id from bots";
    $bots = new Collection($sql);
    $bots->bindType("id", "Bot");
    $bots->bindType("queue_id", "Queue");
    foreach ($bots->getAll() as $row) {
        $bot = $row['Bot'];
        $queue = $row['Queue'];
        $sql = "INSERT INTO bot_queues VALUES(?, ?, 1)";
        $data = array($queue->id, $bot->id);
        db()->execute($sql, $data);
    }
    $sql = "DROP INDEX queue_id ON bots";
    db()->execute($sql);
    $sql = "ALTER TABLE bots DROP COLUMN queue_id";
    db()->execute($sql);
    $patch->finish("Added bots to queues");
}
开发者ID:eric116,项目名称:BotQueue,代码行数:24,代码来源:v05p02.php

示例9: Patch

<?php

include "../patches.php";
$patch = new Patch(18);
if (!$patch->exists()) {
    $createSql = "CREATE TABLE IF NOT EXISTS `webcam_images` (\n\t\t\t  `timestamp` datetime NOT NULL,\n\t\t\t  `image_id` bigint(11) unsigned NOT NULL,\n\t\t\t  `user_id` int(11) unsigned NOT NULL,\n\t\t\t  `bot_id` int(11) unsigned NULL,\n\t\t\t  `job_id` int(11) unsigned NULL,\n\t\t\t  PRIMARY KEY (`timestamp`, `image_id`),\n\t\t\t  FOREIGN KEY (`image_id`) REFERENCES s3_files(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`user_id`) REFERENCES users(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`bot_id`) REFERENCES bots(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`job_id`) REFERENCES jobs(`id`) ON DELETE CASCADE\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
    db()->execute($createSql);
    $failCount = 0;
    $rowSql = "SELECT id from jobs where webcam_images!=''";
    $jobsCollection = new Collection($rowSql);
    $jobsCollection->bindType('id', 'Job');
    $jobs = $jobsCollection->getAll();
    $total = $jobsCollection->count();
    $count = 0;
    $patch->progress(0);
    // Get the current webcam images in an array, so we can quickly skip those.
    $pdoStatement = db()->query("SELECT image_id from webcam_images");
    $existingImages = array();
    foreach ($pdoStatement->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $existingImages[$row['image_id']] = true;
    }
    foreach ($jobs as $row) {
        /** @var Job $job */
        $job = $row['Job'];
        $images_json = $job->get('webcam_images');
        if ($job->isHydrated() && $images_json != "") {
            $images = json_decode($images_json, true);
            $rowData = array();
            foreach ($images as $timestamp => $image_id) {
                if (!array_key_exists($image_id, $existingImages)) {
                    $file = Storage::get($image_id);
开发者ID:eric116,项目名称:BotQueue,代码行数:31,代码来源:v05p06.php

示例10: merge

 /**
  * Returns a new collection with the items from this collection and the provided combined.
  *
  * @param Collection $collection
  *
  * @return Collection
  */
 public function merge(Collection $collection)
 {
     return new Collection(array_merge($this->items, $collection->getAll()));
 }
开发者ID:michaelyin1,项目名称:Modern-Toolkit,代码行数:11,代码来源:Collection.php

示例11: renderCSV

 /**
  * Exports CSV
  */
 protected function renderCSV()
 {
     // exports orders
     if (Tools::isSubmit('csv_orders')) {
         $ids = array();
         foreach ($this->_list as $entry) {
             $ids[] = $entry['id_supply_order'];
         }
         if (count($ids) <= 0) {
             return;
         }
         $id_lang = Context::getContext()->language->id;
         $orders = new Collection('SupplyOrder', $id_lang);
         $orders->where('is_template', '=', false);
         $orders->where('id_supply_order', 'in', $ids);
         $id_warehouse = $this->getCurrentWarehouse();
         if ($id_warehouse != -1) {
             $orders->where('id_warehouse', '=', $id_warehouse);
         }
         $orders->getAll();
         $csv = new CSV($orders, $this->l('supply_orders'));
         $csv->export();
     } else {
         if (Tools::isSubmit('csv_orders_details')) {
             // header
             header('Content-type: text/csv');
             header('Content-Type: application/force-download; charset=UTF-8');
             header('Cache-Control: no-store, no-cache');
             header('Content-disposition: attachment; filename="' . $this->l('supply_orders_details') . '.csv"');
             // echoes details
             $ids = array();
             foreach ($this->_list as $entry) {
                 $ids[] = $entry['id_supply_order'];
             }
             if (count($ids) <= 0) {
                 return;
             }
             // for each supply order
             $keys = array('id_product', 'id_product_attribute', 'reference', 'supplier_reference', 'ean13', 'upc', 'name', 'unit_price_te', 'quantity_expected', 'quantity_received', 'price_te', 'discount_rate', 'discount_value_te', 'price_with_discount_te', 'tax_rate', 'tax_value', 'price_ti', 'tax_value_with_order_discount', 'price_with_order_discount_te', 'id_supply_order');
             echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $keys)));
             // overrides keys (in order to add FORMAT calls)
             $keys = array('sod.id_product', 'sod.id_product_attribute', 'sod.reference', 'sod.supplier_reference', 'sod.ean13', 'sod.upc', 'sod.name', 'FORMAT(sod.unit_price_te, 2)', 'sod.quantity_expected', 'sod.quantity_received', 'FORMAT(sod.price_te, 2)', 'FORMAT(sod.discount_rate, 2)', 'FORMAT(sod.discount_value_te, 2)', 'FORMAT(sod.price_with_discount_te, 2)', 'FORMAT(sod.tax_rate, 2)', 'FORMAT(sod.tax_value, 2)', 'FORMAT(sod.price_ti, 2)', 'FORMAT(sod.tax_value_with_order_discount, 2)', 'FORMAT(sod.price_with_order_discount_te, 2)', 'sod.id_supply_order');
             foreach ($ids as $id) {
                 $query = new DbQuery();
                 $query->select(implode(', ', $keys));
                 $query->from('supply_order_detail', 'sod');
                 $query->leftJoin('supply_order', 'so', 'so.id_supply_order = sod.id_supply_order');
                 $id_warehouse = $this->getCurrentWarehouse();
                 if ($id_warehouse != -1) {
                     $query->where('so.id_warehouse = ' . (int) $id_warehouse);
                 }
                 $query->where('sod.id_supply_order = ' . (int) $id);
                 $query->orderBy('sod.id_supply_order_detail DESC');
                 $resource = Db::getInstance()->query($query);
                 // gets details
                 while ($row = Db::getInstance()->nextRow($resource)) {
                     echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
                 }
             }
         } else {
             if (Tools::isSubmit('csv_order_details') && Tools::getValue('id_supply_order')) {
                 $supply_order = new SupplyOrder((int) Tools::getValue('id_supply_order'));
                 if (Validate::isLoadedObject($supply_order)) {
                     $details = $supply_order->getEntriesCollection();
                     $details->getAll();
                     $csv = new CSV($details, $this->l('supply_order') . '_' . $supply_order->reference . '_details');
                     $csv->export();
                 }
             }
         }
     }
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:75,代码来源:AdminSupplyOrdersController.php

示例12: live

 public function live()
 {
     $this->assertAdmin();
     $this->setTitle("Live Bots View");
     $sql = "SELECT id, job_id FROM bots WHERE webcam_image_id != 0 AND last_seen > NOW() - 3600 ORDER BY last_seen DESC";
     $bots = new Collection($sql);
     $bots->bindType('id', 'Bot');
     $bots->bindType('job_id', 'Job');
     $this->set('bots', $bots->getAll());
     $this->set('dashboard_style', 'medium_thumbnails');
 }
开发者ID:eric116,项目名称:BotQueue,代码行数:11,代码来源:bot.php

示例13: function

$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/collections", function () use($app) {
    return $app['twig']->render('collections.html.twig', array('collections' => Collection::getAll()));
});
$app->get("/types", function () use($app) {
    return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->get("/searches", function () use($app) {
    return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll()));
});
$app->post("/collections", function () use($app) {
    $collection = new Collection($_POST['thing']);
    $collection->save();
    return $app['twig']->render('collections.html.twig', array('collections' => Collection::getAll()));
});
$app->post("/types", function () use($app) {
    $type = new Type($_POST['descript']);
    $type->save();
    return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->post("/searches", function () use($app) {
    $search = new Search($_POST['find']);
    $search->save();
    return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll()));
});
$app->post("/delete_collections", function () use($app) {
    Collection::deleteAll();
    return $app['twig']->render('delete_collections.html.twig');
});
开发者ID:jmalo34,项目名称:Inventory_Collection,代码行数:31,代码来源:app.php

示例14: renderCSV


//.........这里部分代码省略.........
             $product->leftjoin('erpip_zone', 'subarea', '(subarea.id_erpip_zone = ewpl.id_zone)');
             // apply filters
             if ($id_warehouse != -1) {
                 $product->where('s.id_warehouse = ' . (int) $id_warehouse . ' OR wpl.id_warehouse = ' . (int) $id_warehouse);
                 // Area
                 if (Tools::isSubmit('area')) {
                     $product->where('ewpl.id_zone_parent= ' . intval(Tools::getValue('area')));
                     // sub area
                     if (Tools::isSubmit('subarea')) {
                         $product->where('ewpl.id_zone= ' . intval(Tools::getValue('subarea')));
                     }
                 }
             }
             if ($id_category != -1) {
                 $product->where('p.id_product IN (' . implode(', ', array_map('intval', $categories)) . ')');
             }
             if ($id_supplier != -1) {
                 $product->where('p.id_product IN (' . implode(', ', array_map('intval', $suppliers)) . ')');
             }
             if ($id_manufacturer != -1) {
                 $product->where('p.id_product IN (' . implode(', ', array_map('intval', $manufacturers)) . ')');
             }
             if ($moreless != -1) {
                 if ($quantity > 0) {
                     $where_quantity_filter = ' physical_quantity ' . $moreless . ' ' . (int) $quantity;
                     if ($moreless == '=' && $quantity == 0 || $moreless == "<" && $quantity > 0) {
                         $where_quantity_filter .= ' OR physical_quantity IS NULL';
                     }
                 }
                 $product->where($where_quantity_filter);
             }
             if (count($ids) > 0) {
                 $product->where("p.id_product NOT IN (" . implode(',', array_map('intval', $ids)) . ")");
             }
             $product->groupBy('p.id_product, w.id_warehouse');
             $product->orderBy('p.id_product');
             if ($this->controller_status == STATUS1) {
                 $product->limit($stckmgtfr);
                 $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits document editing to %d products'), $stckmgtfr);
             }
             $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($product);
             // $query = array_merge($products, $combinations);
             $query = array_merge($products, $combinations);
             // we sort by id_product and id_product_attribute
             usort($query, array($this, "idproductSort"));
             if ($this->controller_status == STATUS1) {
                 $query = array_splice($query, 0, $stckmgtfr);
             }
             $csv_header_columns = array($this->l('EAN13'), $this->l('ID_PRODUCT'), $this->l('ID_PRODUCT_ATTRIBUTE'), $this->l('REFERENCE'), $this->l('PHYSICAL_QUANTITY'), $this->l('USABLE_QUANTITY'), self::transformText($this->l('WAREHOUSE')), $this->l('AREA'), $this->l('SUBAREA'), $this->l('LOCATION'), $this->l('WARNING'));
             echo implode(';', $csv_header_columns) . "\r\n";
             // generate csv file
             foreach ($query as $product) {
                 //alert in the case where the product has stock in warehouse without be located in this warehouse
                 $warning = '';
                 if (is_null($product['id_warehouse_product_location'])) {
                     $warning = sprintf($this->l('Product has stock in %s warehouse without being registered in this warehouse !'), $product['warehouse']);
                 }
                 $csv_value_columns = array(self::transformText($product['ean13']), $product['id_product'], $product['id_product_attribute'], self::transformText($product['reference']), self::transformText($product['physical_quantity']), self::transformText($product['usable_quantity']), self::transformText($product['warehouse']), self::transformText($product['areaname']), self::transformText($product['subareaname']), self::transformText($product['location']), self::transformText($warning));
                 echo implode(';', $csv_value_columns) . "\r\n";
             }
             echo sprintf($this->l('You are using the free version of 1-Click ERP which limits the export to %d products'), $stckmgtfr);
         } else {
             // we work in different stock table while advanced stock is disabled
             $table_stock = 'StockAvailable';
             $table_quantity = 'quantity';
             // create collection width current filter
             $id_lang = Context::getContext()->language->id;
             $stock = new Collection($table_stock, $id_lang);
             if ($id_category != -1) {
                 $stock->where('id_product', 'in', $categories);
             }
             if ($id_supplier != -1) {
                 $stock->where('id_product', 'in', $suppliers);
             }
             if ($id_manufacturer != -1) {
                 $stock->where('id_product', 'in', $manufacturers);
             }
             if ($moreless != -1) {
                 if ($quantity > 0) {
                     $where_quantity_filter = $table_quantity . ' ' . $moreless . ' ' . $quantity;
                     if ($moreless == '=' && $quantity == 0 || $moreless == "<" && $quantity > 0) {
                         $where_quantity_filter .= ' OR ' . $table_quantity . ' IS NULL';
                     }
                 }
                 $stock->sqlWhere($where_quantity_filter);
             }
             $stock->orderBy('id_product');
             $stock->orderBy('id_product_attribute');
             $stock->getAll();
             if ($this->controller_status == STATUS1) {
                 $stock = array_splice($stock, 0, $stckmgtfr);
                 $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits document editing to %d products'), $stckmgtfr);
             }
             // generation of CSV
             $csv = new CSV($stock, $this->l('stock') . '_' . date('Y-m-d_His'));
             $csv->export();
         }
         die;
     }
 }
开发者ID:prestamodule,项目名称:erpillicopresta,代码行数:101,代码来源:AdminAdvancedStock.php


注:本文中的Collection::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。