Exemplo n.º 1
0
 | Copyright (c) 2013-2016 Phalcon Team and contributors                  |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to license@phalconphp.com so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
*/
/**
 * This script generates random posts
 */
require 'cli-bootstrap.php';
$faker = Faker\Factory::create();
$log = new Phalcon\Logger\Adapter\Stream('php://stdout');
$log->info('Start');
/** @var Phalcon\Db\AdapterInterface $database */
$database = $di->getShared('db');
$database->begin();
for ($i = 0; $i <= 20; $i++) {
    $title = $faker->company;
    $category = new Phosphorum\Models\Categories();
    $category->name = $title;
    $category->description = $faker->sentence;
    $category->slug = Phalcon\Tag::friendlyTitle($title);
    $category->number_posts = 0;
    $category->no_bounty = 'N';
    $category->no_digest = 'N';
    $category->description = $faker->text;
    if (!$category->save()) {
<?php

$logger = new \Phalcon\Logger\Adapter\Stream("php://stderr");
$logger->log("This is a message");
$logger->log("This is an error", \Phalcon\Logger::ERROR);
$logger->error("This is another error");