public function load(ObjectManager $manager) { // Liste des noms de catégorie à ajouter // $project = array[ // array[ // "name" => "", // "date_livraison" => "", // "type" => "", // "langage" // ], // 'SIG', // 'Node.js Video App', // 'Design Telma Gap', // 'App Android', // 'DagoVideo' // ]; foreach ($names as $name) { // On crée la catégorie $category = new Category(); $category->setName($name); // On la persiste $manager->persist($category); } // On déclenche l'enregistrement de toutes les catégories $manager->flush(); }
public function create($name, $description) { $category = new Category($this->db); try { $category->setName($name); $category->setDescription($description); } catch (Exception $e) { $err = $e->getMessage(); } if (!isset($err)) { $name = $this->db->quote($category->getName()); $description = $this->db->quote($category->getDescription()); $query = ' INSERT INTO category (name, description) VALUES (' . $name . ', ' . $description . ')'; $res = $this->db->exec($query); if ($res) { $id = $this->db->lastInsertId(); if ($id) { return $this->readById($id); } else { throw new Exception('Database error'); } } else { throw new Exception("Database error"); } } else { throw new Exception($err); } }
/** * @param Category $category * @param $values * @return Category */ protected function edit(Category $category, $values) { $parent = $this->categoryFacade->getOne($values['parent']); $category->setName($values['name'])->setSlug($values->slug)->setDescription($values['description'])->setParent($parent); $this->categoryFacade->save($category); return $category; }
public function doSave($con = null) { parent::doSave($con); if (!$this->getValue('parent')) { $treeObject = Doctrine_Core::getTable('Category')->getTree(); $roots = $treeObject->fetchRoots(); //If root was deleted, recreate if (count($roots) == 0) { $rootCategory = new Category(); $rootCategory->setName("Categories"); $rootCategory->setActive(true); $rootCategory->save(); $treeObject->createRoot($rootCategory); $parent = $rootCategory; } else { $parent = Doctrine::getTable('Category')->findOneById($roots[0]['id']); } if ($this->isNew()) { $this->getObject()->getNode()->insertAsFirstChildOf($parent); } else { $this->getObject()->getNode()->moveAsFirstChildOf($parent); } } elseif ($this->getValue('parent')) { $parent = Doctrine::getTable('Category')->findOneById($this->getValue('parent')); if ($this->isNew()) { $this->getObject()->getNode()->insertAsLastChildOf($parent); } else { $this->getObject()->getNode()->moveAsLastChildOf($parent); } } }
public function load(ObjectManager $manager) { $category = new Category(); $category->setName("Category Name"); $manager->persist($category); $manager->flush(); }
public function executeInsertCategory(sfWebRequest $request) { if ($request->hasParameter("categoryid") && $request->hasParameter("categoryname")) { $parent = Doctrine_Core::getTable('Category')->findOneById($request->getParameter("categoryid")); $category = new Category(); $category->setName($request->getParameter("categoryname")); $category->setActive(true); $category->getNode()->insertAsLastChildOf($parent); return true; } }
public function getCategory($category_id) { $db = Database::getDB(); $query = "SELECT * FROM categories\n WHERE categoryID = '{$category_id}'"; $statement = $db->query($query); $row = $statement->fetch(); $category = new Category(); $category->setID($row['categoryID']); $category->setName($row['categoryName']); return $category; }
function testSetName() { //Arrange $name = "Kitchen chores"; $test_category = new Category($name); //Act $test_category->setName("Home chores"); $result = $test_category->getName(); //Assert $this->assertEquals("Home chores", $result); }
function testSetName() { // Arrange $name = "Work stuff"; $test_category = new Category($name); // Act $test_category->setName("Work"); $result = $test_category->getName(); // Assert $this->assertEquals("Work", $result); }
private function parseForm(HTTPRequest $request, Category $category) { $name = htmlspecialchars($request->postData('name')); $description = htmlspecialchars($request->postData('description')); $isRoot = !$request->postExists('parent-category'); $category->setName($name); $category->setIsRoot($isRoot); $category->setDescription($description); if (!$isRoot) { $parentCategoryId = $request->postData('parent-category'); $category->setParentCategoryId($parentCategoryId); } }
/** * Create new Category */ public function create() { if ($this->slim->request->isGet()) { $this->slim->render('category/create.html.twig', ['sessionUser' => $this->getSessionUser()]); } elseif ($this->slim->request->isPost()) { $name = $_POST['name']; $newCategory = new Category($this->slim->db); $newCategory->setName($name); $newCategory->insert(); $this->slim->flash('success', 'Category created'); $this->slim->redirect('/categories'); } }
public function testPopulateWithPlace() { $point = new Point(); $point->setLat('-23.59243454'); $point->setLng('-46.68677054'); $city = new City(); $city->setCountry('BR'); $city->setState('SP'); $city->setName('São Paulo'); $category = new Category(); $category->setId('123'); $category->setName('Empresas de Internet'); $address = new Address(); $address->setStreet("Rua Funchal"); $address->setNumber(129); $address->setComplement('6o andar'); $address->setCity($city); $place = new Place(); $place->setId("M25GJ288"); $place->setName("Apontador.com - São Paulo"); $place->setDescription("Líder em geolocalização no Brasil e uma das 250 maiores empresas de internet do mundo, segundo o AlwaysOn, o Apontador (www.apontador.com) desenvolve e oferece serviços e ferramentas de busca e localização para facilitar o dia a dia dos usuários, além de mostrar a opinião do público para os locais cadastrados em seus sites. Com mais de 10 milhões de visitantes mensais, a empresa inclui o site líder em busca local Apontador (www.apontador.com.br) e o de mapas e rotas MapLink (www.maplink.com.br)."); $place->setIconUrl("http://localphoto.s3.amazonaws.com/C40372534F143O1437_9896391605729015_l.jpg"); $place->setPoint($point); $place->setCategory($category); $place->setAddress($address); $this->og->populate($place); $rootUrl = \ROOT_URL; $testMeta = <<<META \t<meta property="og:title" content="Apontador.com - São Paulo"/> \t<meta property="og:description" content="Líder em geolocalização no Brasil e uma das 250 maiores empresas de internet do mundo, segundo o AlwaysOn, o Apontador (www.apontador.com) desenvolve e oferece serviços e ferramentas de busca e localização para facilitar o dia a dia dos usuários, além de mostrar a opinião do público para os locais cadastrados em seus sites. Com mais de 10 milhões de visitantes mensais, a empresa inclui o site líder em busca local Apontador (www.apontador.com.br) e o de mapas e rotas MapLink (www.maplink.com.br)."/> \t<meta property="og:image" content="http://maplink.com.br/widget?v=4.1&lat=-23.59243454&lng=-46.68677054"/> \t<meta property="og:url" content="{$rootUrl}sp/s-o-paulo/empresas-de-internet/apontador-com-s-o-paulo/M25GJ288.html"/> \t<meta property="og:street-address" content="Rua Funchal, 129"/> \t<meta property="og:locality" content="São Paulo"/> \t<meta property="og:region" content="SP"/> \t<meta property="og:country-name" content="Brasil"/> \t<meta property="og:latitude" content="-23.59243454"/> \t<meta property="og:longitude" content="-46.68677054"/> \t<meta property="og:type" content="company"/> META; $this->assertEquals($testMeta, $this->og->getMeta()); $testArray = array('title' => 'Apontador.com - São Paulo', 'description' => 'Líder em geolocalização no Brasil e uma das 250 maiores empresas de internet do mundo, segundo o AlwaysOn, o Apontador (www.apontador.com) desenvolve e oferece serviços e ferramentas de busca e localização para facilitar o dia a dia dos usuários, além de mostrar a opinião do público para os locais cadastrados em seus sites. Com mais de 10 milhões de visitantes mensais, a empresa inclui o site líder em busca local Apontador (www.apontador.com.br) e o de mapas e rotas MapLink (www.maplink.com.br).', 'image' => 'http://maplink.apontador.com.br/widget?v=4.1&lat=-23.59243454&lng=-46.68677054', 'url' => ROOT_URL . 'sp/s-o-paulo/empresas-de-internet/apontador-com-s-o-paulo/M25GJ288.html', 'street-address' => 'Rua Funchal, 129', 'locality' => 'São Paulo', 'region' => 'SP', 'country-name' => 'Brasil', 'latitude' => '-23.59243454', 'longitude' => '-46.68677054', 'type' => 'company'); $this->assertEquals($testArray, $this->og->getArray()); }
public function testPopulateWithPlace() { $point = new Point(); $point->setLat('-23.59243454'); $point->setLng('-46.68677054'); $city = new City(); $city->setCountry('BR'); $city->setState('SP'); $city->setName('São Paulo'); $category = new Category(); $category->setId('067'); $category->setName('Restaurante'); $address = new Address(); $address->setStreet("R. Min. Jesuino Cardoso"); $address->setNumber(473); $address->setCity($city); $place = new Place(); $place->setId("UCV34B2P"); $place->setName("Uziel Restaurante"); $place->setDescription("Se você procura um restaurante com variedade, qualidade com preço justo você encontra no Uziel restaurante!O preço do kilo é R\$ 26,90, mas você paga no máximo R\$ 15,90 por pesagem de refeições (excluindo sobremesas, bebidas e doces). Acima de 500 gramas você ainda ganha um refrescoUm bom vinho, gelatina e cafezinho são por nossa conta.Se precisar de internet você pode contar com nossa rede Wi-Fi.Nosso cardápio diário possui 5 tipos de carne todos os dias, feijoada completa e separada (feijão e carnes) às quartas, 6 tipos de massa nas quintas e 4 tipos de pizzas nassextas, além de opções de peixes todas as terças e sextas.Oferecemos convênio com descontos progressivos para empresas e um bolo com o sabor a escolha do aniversariante, caso agende com antecedência e traga mais de 10 pessoas para almoçar no seu aniversário.Aceitamos todos os cartões de crédito e vales refeição.Você pode receber nosso cardápio atualizado diariamente pelo twitter http://twitter.com/uzielrestaurant"); $place->setIconUrl("http://maplink.com.br/widget?v=4.1&lat=-23.5926083&lng=-46.6818329"); $place->setPoint($point); $place->setCategory($category); $place->setAddress($address); $this->abm->populate($place); $rootUrl = \ROOT_URL; $testMeta = <<<META \t<meta property="restaurant:title" content="Uziel Restaurante"/> \t<meta property="restaurant:description" content="Se você procura um restaurante com variedade, qualidade com preço justo você encontra no Uziel restaurante!O preço do kilo é R\$ 26,90, mas você paga no máximo R\$ 15,90 por pesagem de refeições (excluindo sobremesas, bebidas e doces). Acima de 500 gramas você ainda ganha um refrescoUm bom vinho, gelatina e cafezinho são por nossa conta.Se precisar de internet você pode contar com nossa rede Wi-Fi.Nosso cardápio diário possui 5 tipos de carne todos os dias, feijoada completa e separada (feijão e carnes) às quartas, 6 tipos de massa nas quintas e 4 tipos de pizzas nassextas, além de opções de peixes todas as terças e sextas.Oferecemos convênio com descontos progressivos para empresas e um bolo com o sabor a escolha do aniversariante, caso agende com antecedência e traga mais de 10 pessoas para almoçar no seu aniversário.Aceitamos todos os cartões de crédito e vales refeição.Você pode receber nosso cardápio atualizado diariamente pelo twitter http://twitter.com/uzielrestaurant"/> \t<meta property="restaurant:image" content="http://maplink.apontador.com.br/widget?v=4.1&lat=-23.59243454&lng=-46.68677054"/> \t<meta property="restaurant:url" content="{$rootUrl}sp/s-o-paulo/restaurante/uziel-restaurante/UCV34B2P.html"/> \t<meta property="restaurant:address" content="R. Min. Jesuino Cardoso, 473"/> \t<meta property="restaurant:city" content="São Paulo"/> \t<meta property="restaurant:state" content="SP"/> \t<meta property="restaurant:country-name" content="Brasil"/> \t<meta property="restaurant:type" content="restaurant"/> META; $this->assertEquals($testMeta, $this->abm->getMeta()); $testArray = array('title' => 'Uziel Restaurante', 'description' => 'Se você procura um restaurante com variedade, qualidade com preço justo você encontra no Uziel restaurante!O preço do kilo é R$ 26,90, mas você paga no máximo R$ 15,90 por pesagem de refeições (excluindo sobremesas, bebidas e doces). Acima de 500 gramas você ainda ganha um refrescoUm bom vinho, gelatina e cafezinho são por nossa conta.Se precisar de internet você pode contar com nossa rede Wi-Fi.Nosso cardápio diário possui 5 tipos de carne todos os dias, feijoada completa e separada (feijão e carnes) às quartas, 6 tipos de massa nas quintas e 4 tipos de pizzas nassextas, além de opções de peixes todas as terças e sextas.Oferecemos convênio com descontos progressivos para empresas e um bolo com o sabor a escolha do aniversariante, caso agende com antecedência e traga mais de 10 pessoas para almoçar no seu aniversário.Aceitamos todos os cartões de crédito e vales refeição.Você pode receber nosso cardápio atualizado diariamente pelo twitter http://twitter.com/uzielrestaurant', 'image' => 'http://maplink.apontador.com.br/widget?v=4.1&lat=-23.59243454&lng=-46.68677054', 'url' => ROOT_URL . 'sp/s-o-paulo/restaurante/uziel-restaurante/UCV34B2P.html', 'address' => 'R. Min. Jesuino Cardoso, 473', 'city' => 'São Paulo', 'state' => 'SP', 'country-name' => 'Brasil', 'type' => 'restaurant'); $this->assertEquals($testArray, $this->abm->getArray()); }
public function create($name, $description, $img) { $category = new Category($this->db); $errors = array(); try { $category->setName($name); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $category->setDescription($description); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $category->setImg($img); } catch (Exception $e) { $errors[] = $e->getMessage(); } if (count($errors) == 0) { $name = $this->db->quote($category->getName()); $description = $this->db->quote($category->getDescription()); $img = $this->db->quote($category->getImg()); $query = "INSERT INTO category (name, description, img) VALUES(" . $name . "," . $description . "," . $img . ")"; $res = $this->db->exec($query); if ($res) { $id = $this->db->lastInsertId(); if ($id) { return $this->findById($id); } else { $errors[] = "Category not found"; return $errors; } } else { $errors[] = "Internal server error"; return $errors; } } else { return $errors; } }
public function importCategories(Import $entity, $output) { $em = $this->container->get('doctrine')->getManager(); $sql = ' SELECT s.id, s.nombre, s.slug FROM `servicio` AS s ' . ' ORDER BY s.id '; // . ' LIMIT '.$entity->getLimitStart().', '.$entity->getLimitEnd(); $link = mysqli_connect($entity->getServer(), $entity->getUsername(), $entity->getPassword(), $entity->getDbname()) or die('No se pudo conectar: ' . mysqli_error($link)); $resultado = $link->query($sql); if (mysqli_num_rows($resultado) > 0) { while ($fila = mysqli_fetch_assoc($resultado)) { //Create Categories $category = new Category(); $category->setName(utf8_encode($fila['nombre'])); $category->setDescription(utf8_encode($fila['nombre'])); $category->setMetaTitle(utf8_encode($fila['nombre'])); $category->setMetaDescription(utf8_encode($fila['nombre'])); $category->setSlug(utf8_encode($fila['slug'])); $em->persist($category); } $em->flush(); } }
public function create(User $currentUser, $name, $description) { $category = new Category($this->database); if ($currentUser) { if ($currentUser->getRights() == 2) { $set = $category->setName($name); if ($set === true) { $set = $category->setDescription($description); if ($set === true) { $name = $this->database->quote($category->getName()); $description = $this->database->quote($category->getDescription()); $query = "INSERT INTO category (name, description)\n\t\t\t\t\t\t\tVALUES (" . $name . ", " . $description . ")"; $result = $this->database->exec($query); if ($result) { $id = $this->database->lastInsertId(); if ($id) { try { return $this->findById($id); } catch (Exception $e) { $errors[] = $e->getMessage(); } } else { throw new Exception("Catastrophe serveur."); } } else { throw new Exception("Catastrophe base de données."); } } else { throw new Exception($set); } } else { throw new Exception($set); } } else { throw new Exception("Erreur : Droits d'administration requis."); } } else { throw new Exception("Erreur : Connexion requise."); } }
public static function generateProducts() { //read in xml document(products) $doc = simplexml_load_file(APPLICATION_PATH . '/../products.xml'); foreach ($doc->category as $cat) { $categoryObj = new Category(); $categoryObj->setUrlKey($cat->urlkey); $categoryObj->setName($cat->name); $categoryObj->save(); } foreach ($doc->product as $product) { $productObj = new Product(); $productObj->setName($product->name); $productObj->setPrice($product->price); $productObj->setSku($product->sku); $productObj->setDateCreated(date('d-m-Y H:i:s', time())); $productObj->setUrlKey($product->urlkey); $productObj->setProductImage($product->image); $productObj->setCategoryId($product->category); $productObj->save(); } }
public function getProducts() { $db = Database::getDB(); $query = 'SELECT * FROM products INNER JOIN categories ON products.categoryID = categories.categoryID'; $result = $db->query($query); $products = array(); foreach ($result as $row) { // create the Category object $category = new Category(); $category->setID($row['categoryID']); $category->setName($row['categoryName']); // create the Product object $product = new Product(); $product->setCategory($category); $product->setId($row['productID']); $product->setName($row['productName']); $product->setDescription($row['productDescription']); $product->setPrice($row['listPrice']); $products[] = $product; } return $products; }
$t->is($category[0], $category1->getId(), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array where the values are the requested column values'); $t->is($category[1], $category1->getName(), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array where the values are the requested column values'); /*********************************************/ /* sfPropelFinder::select() and withColumn() */ /*********************************************/ $t->diag('sfPropelFinder::select() and withColumn()'); ArticlePeer::doDeleteAll(); CategoryPeer::doDeleteAll(); $category1 = new Category(); $category1->setName('cat1'); $category1->save(); $category2 = new Category(); $category2->setName('cat2'); $category2->save(); $article1 = new Article(); $article1->setTitle('art1'); $article1->setCategory($category1); $article1->save(); $article2 = new Article(); $article2->setTitle('art2'); $article2->setCategory($category2); $article2->save(); $article3 = new Article(); $article3->setTitle('art3'); $article3->setCategory($category1); $article3->save(); $finder = sfPropelFinder::from('Article')->
public function fetchAllCategories() { $this->db->select('id,name')->order_by("id", "asc"); $query = $this->db->get('website_forum_categories'); $result = array(); if ($query->rowCount() > 1) { $rows = $this->db->fetchAll($query); do { $row = $rows->current(); $category = new Category(); $category->setName($row->name)->setID($row->id); $result[] = $category; } while ($rows->next()); } else { if ($query->rowCount() == 1) { $row = $this->db->fetch($query); $category = new Category(); $category->setName($row->name)->setID($row->id); $result[] = $category; } else { $category = new Category(); $category->setName("error1"); $category->setID(0); $result[] = $category; } } return $result; }
<? require_once("classes/Category.php"); ?> <? require_once("classes/Text.php"); ?> <? $c = new Category(); $action = $_POST["action"]; $name = $_POST["name"]; $c->setName($name); if ($action == "save") { $insert = TRUE; $errMsg = NULL; if ($name == "") { $errMsg = Text::getText("MissingName"); $insert = FALSE; } if ($insert) { $existing = Category::getByName($name); if ($existing != NULL) { $errMsg = Text::getText("AlreadyExists"); $insert = FALSE; } } if ($insert) { $c->insert(); header("Location: categoryList.php"); exit; } else { $buttonCaption = Text::getText("Add"); include("header.php"); print "<h2>".Text::getText("AddCategory")."</h2>";
* @copyright 2011 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @author Cliff Ingham <*****@*****.**> */ include '../../../configuration.inc'; include './migrationConfig.inc'; include './categoryTranslation.inc'; $pdo = new PDO(MIGRATION_DSN, MIGRATION_USER, MIGRATION_PASS); $sql = "select comp_desc from c_types where c_type1!=0"; $result = $pdo->query($sql); foreach ($result->fetchAll(PDO::FETCH_COLUMN) as $name) { $name = trim($name); $newName = isset($CATEGORIES[$name]) ? $CATEGORIES[$name] : $name; try { $category = new Category($newName); } catch (Exception $e) { $category = new Category(); $category->setName($newName); if (preg_match('/NOTICE/', $name)) { list($type, $notice) = explode(' ', $name); $type = $type == 'RECYCLING' ? 'RECYCLE' : $type; $query = $pdo->prepare('select notice from sanitation_notices where type=?'); $query->execute(array($type)); foreach ($query->fetchAll(PDO::FETCH_COLUMN) as $notice) { $category->updateProblems($notice); } } $category->save(); echo $category->getName() . "\n"; } }
/** * Process add project form * * @param void * @return null */ function add() { $this->wireframe->print_button = false; if ($this->request->isApiCall() && !$this->request->isSubmitted()) { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if if (!Project::canAdd($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $project_data = $this->request->post('project'); if (!is_array($project_data)) { $project_data = array('leader_id' => $this->logged_user->getId(), 'default_visibility' => VISIBILITY_PRIVATE); } // if $this->smarty->assign('project_data', $project_data); if ($this->request->isSubmitted()) { db_begin_work(); $this->active_project = new Project(); // just in case $this->active_project->setAttributes($project_data); $this->active_project->setType(PROJECT_TYPE_NORMAL); $this->active_project->setStatus(PROJECT_STATUS_ACTIVE); $leader = null; if ($this->active_project->getLeaderId()) { $leader = Users::findById($this->active_project->getLeaderId()); if (instance_of($leader, 'User')) { $this->active_project->setLeader($leader); } // if } // if $project_template = null; $project_template_id = array_var($project_data, 'project_template_id'); if ($project_template_id) { $project_template = Projects::findById($project_template_id); } // if $save = $this->active_project->save($project_template); if ($save && !is_error($save)) { // Add user who created a project and leader $this->active_project->addUser($this->logged_user, null, null); if (instance_of($leader, 'User')) { $this->active_project->addUser($leader, null, null); } // if // Clone project template if (instance_of($project_template, 'Project')) { $project_template->copyItems($this->active_project); } else { // Auto assign users... $users = Users::findAutoAssignUsers(); if (is_foreachable($users)) { foreach ($users as $user) { $this->active_project->addUser($user, $user->getAutoAssignRole(), $user->getAutoAssignPermissions()); } // foreach } // if // Create default categories $category_definitions = array(); event_trigger('on_master_categories', array(&$category_definitions)); if (is_foreachable($category_definitions)) { foreach ($category_definitions as $category_definition) { $default_categories = $category_definition['value']; if (!is_foreachable($default_categories)) { $default_categories = array('General'); } // if foreach ($default_categories as $category_name) { if (trim($category_name) != '') { $category = new Category(); $category->log_activities = false; // don't log stuff in DB $category->setName($category_name); $category->setProjectId($this->active_project->getId()); $category->setCreatedBy($this->logged_user); $category->setState(STATE_VISIBLE); $category->setVisibility(VISIBILITY_NORMAL); $category->setModule($category_definition['module']); $category->setController($category_definition['controller']); $category->save(); } // if } // foreach } // foreach } // if } // if db_commit(); if ($this->request->isApiCall()) { $this->serveData($this->active_project, 'project'); } else { flash_success('Project ":name" has been created. Use this page to add more people to the project...', array('name' => $this->active_project->getName())); $this->redirectToUrl($this->active_project->getPeopleUrl()); } // if } else { db_rollback(); if ($this->request->isApiCall()) { $this->serveData($save); } else { $this->smarty->assign('errors', $save); } // if } // if } // if }
} if (!empty($row['phone']['number'])) { $person->setPhoneNumber($row['phone']['number']); } if (!empty($row['phone']['device_id'])) { $person->setPhoneDeviceId($row['phone']['device_id']); } $person->save(); $zend_db->insert('people_crosswalk', array('person_id' => $person->getId(), 'mongo_id' => (string) $row['_id'])); echo "Person: {$person->getFullname()}\n"; } // Load the Categories $result = $mongo->categories->find(); foreach ($result as $r) { $c = new Category(); $c->setName($r['name']); $c->setDescription($r['description']); $c->setDisplayPermissionLevel($r['displayPermissionLevel']); $c->setPostingPermissionLevel($r['postingPermissionLevel']); $g = new CategoryGroup($r['group']['name']); $c->setCategoryGroup($g); $d = new Department($r['department']['name']); $c->setDepartment($d); if (!empty($r['customFields'])) { $c->setCustomFields(json_encode($r['customFields'])); } $c->save(); echo "Category: {$c->getName()}\n"; } // Now that we've got People and Categories in the database, // Link the Departments with their Categories and Default Person
public function testPopulate() { $subCategory = new Subcategory(); $subCategory->setId(1234); $subCategory->setName("Self Service"); $category = new Category(); $category->setId(12); $category->setName("Restaurantes"); $category->setSubCategory($subCategory); $city = new City(); $city->setCountry("Brasil"); $city->setState("SP"); $city->setName("São Paulo"); $address = new Address(); $address->setCity($city); $address->setComplement("1 Andar"); $address->setDistrict("Vila Olímpia"); $address->setNumber("129"); $address->setStreet("Rua Funchal"); $address->setZipcode("04551-069"); $gasStation = new GasStation(array('price_gas' => 1, 23, 'price_vodka' => 23, 45)); $placeInfo = new PlaceInfo(); $placeInfo->setGasStation($gasStation); $data = new \stdClass(); $data->id = 123; $data->name = "Chegamos!"; $data->average_rating = 4; $data->review_count = 3; $data->category = $category; $data->subcategory = $subCategory; $data->address = $address; $data->point->lat = "-23.529366"; $data->point->lng = "-47.467117"; $data->main_url = "http://chegamos.com/"; $data->other_url = "http://chegamos.com.br/"; $data->icon_url = "http://chegamos.com/img/icon.png"; $data->description = "Description"; $data->created = "01/12/2010 16:19"; $data->phone = "11 2222-3333"; $data->extended = $placeInfo; $data->num_visitors = 1024; $data->num_photos = 5; $this->object->populate($data); $this->assertEquals(123, $this->object->getId()); $this->assertEquals("Chegamos!", $this->object->getName()); $this->assertEquals(4, $this->object->getAverageRating()); $this->assertEquals("Bom", $this->object->getAverageRatingString()); $this->assertEquals(3, $this->object->getReviewCount()); $this->assertEquals("app\\models\\Category", \get_class((object) $this->object->getCategory())); $this->assertEquals("Restaurantes - Self Service", (string) $this->object->getCategory()); $this->assertEquals("app\\models\\Address", \get_class((object) $this->object->getAddress())); $this->assertEquals("Rua Funchal, 129 - Vila Olímpia<br/>São Paulo - SP", (string) $this->object->getAddress()); $this->assertEquals("-23.529366,-47.467117", (string) $this->object->getPoint()); $this->assertEquals("http://chegamos.com/", $this->object->getMainUrl()); $this->assertEquals("http://chegamos.com.br/", $this->object->getOtherUrl()); $this->assertEquals("http://chegamos.com/img/icon.png", $this->object->getIconUrl()); $this->assertEquals("Description", $this->object->getDescription()); $this->assertEquals("01/12/2010 16:19", $this->object->getCreated()); $this->assertEquals("11 2222-3333", $this->object->getPhone()); $this->assertEquals("app\\models\\PlaceInfo", \get_class((object) $this->object->getPlaceInfo())); $this->assertEquals(1024, $this->object->getNumVisitors()); $this->assertEquals(5, $this->object->getNumPhotos()); }
public function parseCategories() { $categories = new Categories(); $keyParams = array(); foreach ($this->xmlCategories as $xmlCategory) { $code = $xmlCategory->getCode(); $name = $xmlCategory->getName(); $isAGroup = $xmlCategory->isAGroup(); if (!empty($code) && !in_array($code, $keyParams)) { array_push($keyParams, $code); $category = new Category(); $category->setIsAGroup($isAGroup); $category->setCode($code); $category->setName($name); $categories->setItem($category); } } foreach ($this->xmlCategories as $xmlCategory) { $catCode = $xmlCategory->getCategoryCode(); $code = $xmlCategory->getCode(); $current = $categories->getItemByCode($code); $parent = $categories->getItemByCode($catCode); if ($parent != null) { $current->setParent($parent); } } $categoryDAO = new CategoryDAO(); $categoryDAO->insertItems($categories); return $categories; }
function testNullValueReplacementForGuidValue() { if ($this->hasSupportFor('last_insert_id')) { $category = new Category(); $category->setName("Totoasdasd"); $category->setGuidString('00000000-0000-0000-0000-000000000000'); $key = $this->sqlmap->insert("InsertCategoryNull", $category); $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key); $this->assertSame($category->getName(), $categoryRead->getName()); $this->assertSame('', $categoryRead->getGuidString()); } }
public function get_list($course_sections) { //$result = array(); /*$sig = new Category(); $sig->setName(Category::NAME_SIG); $sig->setSubjects($this->course_sort($signature_required)); $passed = new Category(); $passed->setName(Category::NAME_PASSED); $passed->setSubjects($this->course_sort($courseSections_passed));*/ $rec = new Category(); $rec->setName(Category::NAME_REC); $rec->setSubjects($this->course_sort($course_sections)); //$result['Recommended'] = $rec; //$result['Passed'] = $passed; //$result['Signature'] = $sig; return $rec; }
$obj2 = $categoryRelation->getObjectToRelate($comment1); $t->isa_ok($obj2, 'Article', 'getObjectToRelate() returns a Propel model object'); $t->is($obj2->getTitle(), 'aaaaa', 'getObjectToRelate() returns the object resulting from the previous relation'); /******************************************/ /* sfPropelFinderRelation::relateObject() */ /******************************************/ $t->diag('sfPropelFinderRelation::relateObject()'); CommentPeer::doDeleteAll(); ArticlePeer::doDeleteAll(); CategoryPeer::doDeleteAll(); $category1 = new Category(); $category1->setName('cat1'); $category1->save(); $article1 = new Article(); $article1->setTitle('aaaaa'); $article1->save(); $comment1 = new Comment(); $comment1->setContent('foo'); $comment1->save(); $manager = new sfPropelFinderRelationManager('Comment'); $articleRelation = $manager->guessRelation('Article'); $manager[] = $articleRelation; $categoryRelation = $manager->guessRelation('Category'); $manager[] = $categoryRelation; $articleRelation->relateObject($comment1, $article1);
<?php require '../class/class_category.php'; if (isset($_POST) && !empty($_POST)) { $category = new Category(); $category->setName($_POST['name']); $category->setDescription($_POST["description"]); $category->setPicture(""); $category->create(); var_dump($category); exit; }