-
Posts
840 -
Joined
-
Last visited
-
Days Won
1
Everything posted by gristoi
-
your casuale class dosent have @ORM\Entity at the top of the class
-
ok, we will use 2 entities , with a many to many relationship . We will use article and category, so many articles can have many categories. <?php namespace name\space\here\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="article") */ class Article{ /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue (strategy = "AUTO") */ private $id; /** * @ORM\ManyToMany(targetEntity="Category", inversedBy="articles") * @ORM\JoinTable(name="articles_categories") **/ private $categories; /** * Constructor */ public function __construct() { $this->categories = new \Doctrine\Common\Collections\ArrayCollection(); } public function addCategorie(\your\namespace\here\Entity\Category $categories) { $this->categories[] = $categories; return $this; } public function removeCategorie(\your\namespace\here\Entity\Category $categories) { $this->categories->removeElement($categories); } /** public function getCategories() { return $this->categories; } } Category entity: <?php namespace your\namespace\here\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity * @ORM\Table(name="categories") */ class Category { /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue (strategy = "AUTO") */ private $id; /** * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * @ORM\ManyToMany(targetEntity="Article", mappedBy="categories") **/ private $articles; /** * Constructor */ public function __construct() { $this->articles = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set name * * @param string $name * @return Category */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Add articles * * @param \your\namespace\Entity\Article $articles * @return Category */ public function addArticle(\your\namespace\Entity\Article $articles) { $this->articles[] = $articles; return $this; } /** * Remove articles * * @param \your\namespace\Entity\Article $articles */ public function removeArticle(\your\namespace\Entity\Article $articles) { $this->articles->removeElement($articles); } /** * Get articles * * @return \Doctrine\Common\Collections\Collection */ public function getArticles() { return $this->articles; } public function __toString(){ // seeing as i want the name column of my entity to be displayed i return getname() return $this->getName(); } } then the formtype: ->add('categories', 'entity', array( 'class' => 'yourNamespaceHere:Category', 'expanded'=>false, 'multiple'=>false, ))
-
Your close. You need to read the documentation though. You are trying to populate the dropdown from the repository, this is incorrect, that is why you are getting the not mapped error. Any entity that you use in a form has to have a __toString method in it , this allows the form builder to map the data accordingly. The value returned by the _toString method needs to be whatever you want to show in the dropdown,i.e: $builder->add('nominativo','entity', array('class' => 'FatturazioneFatturazioneBundle:Nominativo')); // then in your Nominativo Entity public function __toString(){ //if your entity has a $name value return $this->getName(); }
-
Do you not understand what a $_GET variable is? For you pagination to work the link for the next page button would need to pass the required variables accross with it, in this case 'board',http pages are stateless : http://www.mypage.com/page?board=12&somethingelse=something if you dont pass that into the page then $_GET['board'] wont be populated
-
the variable: $_GET['board'] isnt being passed across in the link
-
I have to disagree with you on this one Stefany93. the reason you have themes in the first place is the same reason you are here. you are a php developer not a web developer. Thats why we have templates, there are there to fill a need, not just for non programmers. If your building a website for a large / medium client, then you would not build the layout from scratch, you would pass it to a graphic designer / web developer to come up with the UI. These poeple have had years of experience in design, thats what they are there for
-
The site would look fine, if you stepped back in time to the late 90's, unfortunately I would go back to scratch and try and get your money back from the developer. If you have no idea about design there are tons of free templates out there, and some of the cheap ones aren't too bad either. have a look at themeforest.net for a portfolio layout, you can get one for around £10
-
try using the correct funciton name : mysql_connect( ), not mysql connect( )
- 18 replies
-
- configuration
- php
-
(and 2 more)
Tagged with:
-
you should be using the entity type for this: $builder->add('nominativo', 'entity', array( 'class' => 'YourBundlenameHere:Nominativo')) This will automatically pull in all of your options
-
I would look at the codes encapsulaiton and extensibility
-
is a textarea, dosent go into value, try this: <textarea id="comments" name="comments"><?php if (isset($articleDetails['comments']) && $articleDetails['comments'] != NULL) echo $articleDetails['comments']; ?></textarea>
-
a litle quick cheat to convert an xml string into a php array: $phpArray = json_decode(json_encode($xmlString)); if you do that then look at the outputted array it should point you in the right direction
-
$result is not returning any results, problem with your query
-
mysql_query("INSERT INTO `userBooks` (`user_id`,`book_id`) VALUES ('$sessionUserId', '$lastId')"); you were missing the braces
-
Undefined Errors Cannot get user report right
gristoi replied to myironworkers's topic in PHP Coding Help
you have got no conditional logic around any of your get variables, so when you first load the form none of these will exist. you need to do something along the lines of: <?php if(array_key_exists('firstName', $_GET)){ $firstName = $_GET['firstName']; } ?> -
if they are blank rows, then one option is to delete al the blank rows, then run : ALTER TABLE `you_table_name_here` AUTO_INCREMENT = <the last row +1, so if you have 900 records it would be 901>; thats should reset the counter on the auto increment for you. Backup your data first though !!!!!!!!!!!
-
Use jquery to listen to the click event of div holding their starting time, dont use a promtp, use a dialog ( google jquery dialog ). Using that when the user has selected their duration and hit submit, you can shoot off an ajax call to a php script. That will take in the variable as a GET | POST variable and insert into db
-
$error = $_GET['error']; if ($error==1) { echo"value is 1"; }
-
try googling 'PHP and javascript form validation'
-
you cannot have any output before using a header redirect. move your php part of the script to the top of the page
-
Sounds like jquery and ajax are going to be your best bet.
-
application design when programming a website from scratch
gristoi replied to Afelk's topic in Application Design
One of the more popular methodologies is the M V C approach ( Model - View - Controller ) . Have a google on 'PHP design patterns'. You will also find a lot of the frameworks in use today use this pattern- 9 replies
-
- application design
- programming theory
-
(and 1 more)
Tagged with:
-
have a look at sencha touch and jquery mobile
-
Problem pulling from the datbase and displaying on webpage
gristoi replied to popcop's topic in PHP Coding Help
where is the mysql to actually execute the query??