Search Results

Search found 404 results on 17 pages for 'doctrine odm'.

Page 16/17 | < Previous Page | 12 13 14 15 16 17  | Next Page >

  • Join unrelated tables through a second level connected table

    - by Andy M
    Hello! I have two tables of activities on a page: Views & Comments. Views id timestamp project_id user_id page_id Comments id timestamp project_id user_id page_id comment Pages id project_id title Now pages are related to projects: Projects id account_id title I am trying to create a summary page that combines views and comments ordered by time (so that the most recent views/comments are at the beginning, grouped by projects. Also, only projects for a specific account. So the result could potentially be: Project 1 View 5 (June 20th) View 4 (June 18th) Comment 5 (June 15th) Comment 4 (June 14th) Comment 3 (June 12th) Project 3 View 3 (June 10th) View 2 (June 8th) Comment 2 (June 7th) Project 2 View 1 (June 5th) Comment 1 (June 4th) If you could help with how to do this using SQL (or even doctrine) that would be awesome. Thank you.

    Read the article

  • Why is $file empty in custom symfony file validator?

    - by codecowboy
    I am setting a custom file validator for a file input field in Symfony 1.4 (Doctrine) $this-setValidator('filename', new sfValidatorFile(array( 'mime_types' = 'web_images', 'path' = sfConfig::get('sf_upload_dir').'/animals', 'validated_file_class' = 'CustomValidatedFile', 'required' =false ))); I then want to override the save method to generate some thumbnails: class CustomValidatedFile extends sfValidatedFile { private $savedFilename; // Override sfValidatedFile's save method public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777) { $this-savedFilename = $this-generateFilename(); // This makes sure we use only one savedFilename (it will be the first) if ($this-savedFilename === null ) { $this-savedFilename = $file; } $thumbnail = new sfThumbnail(150,150); $thumbnail-loadFile($this-getTempName()); $thumbnail-save(sfConfig::get('sf_upload_dir').'/thumbnails/thumb_'.$this-savedFilename); // Let the original save method do its magic :) return parent::save($this->savedFilename, $fileMode, $create, $dirMode); } } This fails with the error "The file "" is not readable." This is coming from sfThumbnailPlugin because the value of $file is null. My question is why is $file null?

    Read the article

  • how to handle exceptions/errors in php?

    - by fayer
    when using 3rd part libraries they tend to throw exceptions to the browser and hence kill the script. eg. if im using doctrine and insert a duplicate record to the database it will throw an exception. i wonder, what is best practice for handling these exceptions. should i always do a try...catch? but doesn't that mean that i will have try...catch all over the script and for every single function/class i use? Or is it just for debugging? i don't quite get the picture. Cause if a record already exists in a database, i want to tell the user "Record already exists". And if i code a library or a function, should i always use "throw new Expcetion($message, $code)" when i want to create an error? Please shed a light on how one should create/handle exceptions/errors. Thanks

    Read the article

  • frameworks for coding a php library?

    - by ajsie
    there are plenty of frameworks for coding MVC web applications. this time im going to code a library (think of Doctrine or Solr) with a bunch of class files. u just include a bootstrap or a class file and you are ready to use my classes. i have never tried to code a library before and intend to code one for learning purpose so that i can use various design patterns i have learned. are there any great frameworks for this, how i should organize the different class files, where i can put configuration files and so on? tutorials or other information would be great too. thanks

    Read the article

  • How to allow certain HTML tags in a form field in Symfony 1.2

    - by camomileCase
    I'm playing around with Symfony and have encountered a road block. I created a model "CmsPage" which has a field called "content" which is stored as a clob (this is specific to doctrine I believe). When I created the app I set "--escaping-strategy=on" so if I enter any html when editing a CmsPage that gets encoded with html entities or something along those lines. I would like to allow html in this field and a quick googling hasn't helped much. Maybe I'm searching for the wrong terms. Anywho I would like to disable character escaping for this field and possibly only allow a small selection of html tags. What is the correct way to do this in Symfony?

    Read the article

  • how to prevent database to add slash to quotes

    - by black sensei
    i know this sounds really common and so trivial but , am having a challenge here. I have a web site with Zend/Doctrine and i use ckeditor for the backend management. after uploading the site i've realized that during edit testing the look and feel of the site is messed up. with the help of firebug, i've seen that there are slashes all over the html. after inline edition, the look and feel came back to normal. There are so many files , i can't think of doing other decoding before outputting data from mysql. What options do i have to solve this problem. the site is up already and i feel a bit unconfortable about this. Can anyone give a hint? thanks

    Read the article

  • Improve SQL strategy - denormalize in object-children-images case

    - by fesja
    Hi, I have a Tour object which has many Place objects. For the list of tours, I want to show some info of the tour, the number of places of the tour, and three Place's images. Right one my SQL queries are (i'm using Doctrine with Symfony on MySQL) get Tour get Tour 1 places get Tour 2 places get Tour 3 places ... get Tour n places If I have a three Tour list, it's not so bad; but I'm sure it can get bad if I do a 10-20 tour-list. So, thinking on how to improve the queries I've thought of several measures: Having a place count cache Storing the urls of three images on a new tour field. The problem with 2. is that if I change the image, I have to check all the tours to update that image for another one. What solution do you think is best to scale the system in a near future? Any other suggestion. thanks!

    Read the article

  • Weird error: [Semantical Error] line 0, col 75 near 'submit': Error: 'submit' is not defined.

    - by luxury
    My controller like: /** * @Route("/product/submit", name="product_submit") * @Template("GaorenVendorsBundle:Product:index.html.twig") */ public function submitAction() { $em = $this->getDoctrine()->getManager(); $uid = $this->getUser()->getId(); $em->getRepository( 'GaorenVendorsBundle:Product' )->updateStatus( $uid, Product::STATUS_FREE, Product::STATUS_PENDING ); return $this->redirect( $this->generateUrl( 'product' ) ); } and the repo like: class ProductRepository extends EntityRepository { public function updateStatus($uid, $status, $setter) { $st = $this->getEntityManager()->getRepository( 'GaorenVendorsBundle:Product' ) ->createQueryBuilder( 'p' ) ->update( 'GaorenVendorsBundle:Product', 'p' ) ->set( 'p.status', ':setter' ) ->where( 'p.status= :status AND p.user= :user' ) ->setParameters( array( 'user' => $uid, 'status' => $status, 'setter' => $setter ) ) ->getQuery() ->execute() return $st; } when request the "submit" action, it prompts me "[Semantical Error] line 0, col 75 near 'submit': Error: 'submit' is not defined. ". "submit" is nothing to do with DOCTRINE orm query, why it appears in the error? I just can't figure out.Anyone could tell me?

    Read the article

  • many-to-many relationship in CI (not using ORM)

    - by Ross
    I'm implementing a categories system in my CI app and trying to work out the best way of working with many to many relationships. I'm not using an ORM at this stage, but could use say Doctrine if necessary. Each entry may have multiple categories. I have three tables (simplified) Entries: entryID, entryName Categories: categoryID, categoryname Entry_Category: entryID, categoryID my CI code returns a record set like this: entryID, entryName, categoryID, categoryName but, as expected with Many-to-Many relationships, each "entry" is repeated for each "category". What would the best way to "group" the categories so that when I output the results, I am left with something like: Entry Name Appears in Category: Foo, Bar rather than: Entry Name Appears in Category: Foo Entry Name Appears in Category: Bar I believe the option is to track if the post ID matches a previous entry, and if so, store the respective category, and output it as one, rather than several, but am unsure of how to do this in CI. thanks for any pointers (I appreciate this is may be a vague/complex question without a better knowledge of the system).

    Read the article

  • To File Share or to not File Share, that is the Question.

    To file share or to not file share, that is the question. The concept of the internet was developed in the 1960’s as a revolutionary idea to share information and data amongst a group of computers. The original concept was to allow universities and the United States Military share data for research and field operations. This network of computers was designed to provide redundant data storage and communications in case one or more locations were destroyed. Since the inception of the internet, people have attempted to use it for sharing data. As the Internet has evolved so did the users and the information they wanted to share. In today’s modern internet people can share information through various avenues, for example: websites, social networks, email, documents, executable files, data files and much more.  Unfortunately, as the internet and its users have grown, some industries have not paid attention. Currently, there are several industries that have really fallen behind in keeping up with current trends, and are severely paying the price for their lack of action. A current example of this is with the Recording Industry Association of America (RIAA) and file sharing. RIAA contends that customers who purchase music can only listen to the music and cannot share it with others. This can be seen when the RIAA sued Napster for distributing copyrighted music through a technology called file sharing. File sharing as defined by the Media Awareness Network is downloadable software that permits users to share music, video, image or book files directly with peers. Users of file sharing networks simply had to extract the music from a CD into a music compatible format. Typically most music files at that time where saved as MPEG file format. Once the users got music in this format it was very easy share their music with others. The big question now is who actually owns the music, does the music industry still retain the rights of the music regarding who has access to listen to it, or is it up to the owner of the music CD.  According to the First – Sale Doctrine, it is the right of the purchaser of the CD to decide who can access the information on the CD. In addition, the original owner looses all rights to the music once it has been sold.  The importance of defining who actually owns the music has a great impact on the future of the industry. If the industry is determined to be the actual owner of the music then anyone who has shared at least 1 fine with another is guilty of violating the copyright. However, if the owners of the CD are determined to be the owners of the music then the music industry will have to figure out some other way to protect their music so that it is more lucrative for them or they will go out of business. References: http://www.walthowe.com/navnet/history.html http://www.media-awareness.ca/english/resources/special_initiatives/wa_resources/wa_shared/backgrounders/internet_glossary.cfm#F

    Read the article

  • Developing high-performance and scalable zend framework website [on hold]

    - by Daniel
    We are going to develop an ads website like http://www.gumtree.com/ (it will not be like this one but just to give you an ideea) and we are having some issues regarding performance and scalability. We are planning on using Zend Framework for this project but this is all that I'm sure off at this point. I don't think a classic approch like Zend Framework (PHP) + MySQL + Memcache + jQuery (and I would throw Doctrine 2 in there to) will fix result in a high-performance application. I was thinking on making this a RESTful application (with Zend Framework) + NGINX (or maybe MongoDB) + Memcache (or eAccelerator -- I understand this will create problems with scalability on multiple servers) + jQuery or maybe throw Backbone.js in there, a CDN for static content, a server for images and a scalable server for the requests and the rest. My questions are: - What do you think about my approch? - What solutions would you recommand for developing an high performance, scalable application expected to have a lot of traffic using PHP(Zend Framework 2)...I would be interested in your approch. I should note that I'm a Zend developer, I'm working with Zend for over 3 years, this is why I'm choosing it.

    Read the article

  • Developing high-performance and scalable zend framework website

    - by Daniel
    We are going to develop an ads website like http://www.gumtree.com/ (it will not be like this one but just to give you an ideea) and we are having some issues regarding performance and scalability. We are planning on using Zend Framework for this project but this is all that I'm sure off at this point. I don't think a classic approch like Zend Framework (PHP) + MySQL + Memcache + jQuery (and I would throw Doctrine 2 in there to) will fix result in a high-performance application. I was thinking on making this a RESTful application (with Zend Framework) + NGINX (or maybe MongoDB) + Memcache (or eAccelerator -- I understand this will create problems with scalability on multiple servers) + jQuery, a CDN for static content, a server for images and a scalable server for the requests and the rest. My questions are: - What do you think about my approch? - What solutions would you recommand in terms of servers approch (MySQL, NGINX, MongoDB or pgsql) for a scalable application expected to have a lot of traffic using PHP?...I would be interested in your approch. Note: I'm a Zend Framework developer and don't have to much experience with the servers part (to determin what would be best solution for my scalable application)

    Read the article

  • Oracle Data Mining a Star Schema: Telco Churn Case Study

    - by charlie.berger
    There is a complete and detailed Telco Churn case study "How to" Blog Series just posted by Ari Mozes, ODM Dev. Manager.  In it, Ari provides detailed guidance in how to leverage various strengths of Oracle Data Mining including the ability to: mine Star Schemas and join tables and views together to obtain a complete 360 degree view of a customer combine transactional data e.g. call record detail (CDR) data, etc. define complex data transformation, model build and model deploy analytical methodologies inside the Database  His blog is posted in a multi-part series.  Below are some opening excerpts for the first 3 blog entries.  This is an excellent resource for any novice to skilled data miner who wants to gain competitive advantage by mining their data inside the Oracle Database.  Many thanks Ari! Mining a Star Schema: Telco Churn Case Study (1 of 3) One of the strengths of Oracle Data Mining is the ability to mine star schemas with minimal effort.  Star schemas are commonly used in relational databases, and they often contain rich data with interesting patterns.  While dimension tables may contain interesting demographics, fact tables will often contain user behavior, such as phone usage or purchase patterns.  Both of these aspects - demographics and usage patterns - can provide insight into behavior.Churn is a critical problem in the telecommunications industry, and companies go to great lengths to reduce the churn of their customer base.  One case study1 describes a telecommunications scenario involving understanding, and identification of, churn, where the underlying data is present in a star schema.  That case study is a good example for demonstrating just how natural it is for Oracle Data Mining to analyze a star schema, so it will be used as the basis for this series of posts...... Mining a Star Schema: Telco Churn Case Study (2 of 3) This post will follow the transformation steps as described in the case study, but will use Oracle SQL as the means for preparing data.  Please see the previous post for background material, including links to the case study and to scripts that can be used to replicate the stages in these posts.1) Handling missing values for call data recordsThe CDR_T table records the number of phone minutes used by a customer per month and per call type (tariff).  For example, the table may contain one record corresponding to the number of peak (call type) minutes in January for a specific customer, and another record associated with international calls in March for the same customer.  This table is likely to be fairly dense (most type-month combinations for a given customer will be present) due to the coarse level of aggregation, but there may be some missing values.  Missing entries may occur for a number of reasons: the customer made no calls of a particular type in a particular month, the customer switched providers during the timeframe, or perhaps there is a data entry problem.  In the first situation, the correct interpretation of a missing entry would be to assume that the number of minutes for the type-month combination is zero.  In the other situations, it is not appropriate to assume zero, but rather derive some representative value to replace the missing entries.  The referenced case study takes the latter approach.  The data is segmented by customer and call type, and within a given customer-call type combination, an average number of minutes is computed and used as a replacement value.In SQL, we need to generate additional rows for the missing entries and populate those rows with appropriate values.  To generate the missing rows, Oracle's partition outer join feature is a perfect fit.  select cust_id, cdre.tariff, cdre.month, minsfrom cdr_t cdr partition by (cust_id) right outer join     (select distinct tariff, month from cdr_t) cdre     on (cdr.month = cdre.month and cdr.tariff = cdre.tariff);   ....... Mining a Star Schema: Telco Churn Case Study (3 of 3) Now that the "difficult" work is complete - preparing the data - we can move to building a predictive model to help identify and understand churn.The case study suggests that separate models be built for different customer segments (high, medium, low, and very low value customer groups).  To reduce the data to a single segment, a filter can be applied: create or replace view churn_data_high asselect * from churn_prep where value_band = 'HIGH'; It is simple to take a quick look at the predictive aspects of the data on a univariate basis.  While this does not capture the more complex multi-variate effects as would occur with the full-blown data mining algorithms, it can give a quick feel as to the predictive aspects of the data as well as validate the data preparation steps.  Oracle Data Mining includes a predictive analytics package which enables quick analysis. begin  dbms_predictive_analytics.explain(   'churn_data_high','churn_m6','expl_churn_tab'); end; /select * from expl_churn_tab where rank <= 5 order by rank; ATTRIBUTE_NAME       ATTRIBUTE_SUBNAME EXPLANATORY_VALUE RANK-------------------- ----------------- ----------------- ----------LOS_BAND                                      .069167052          1MINS_PER_TARIFF_MON  PEAK-5                   .034881648          2REV_PER_MON          REV-5                    .034527798          3DROPPED_CALLS                                 .028110322          4MINS_PER_TARIFF_MON  PEAK-4                   .024698149          5From the above results, it is clear that some predictors do contain information to help identify churn (explanatory value > 0).  The strongest uni-variate predictor of churn appears to be the customer's (binned) length of service.  The second strongest churn indicator appears to be the number of peak minutes used in the most recent month.  The subname column contains the interior piece of the DM_NESTED_NUMERICALS column described in the previous post.  By using the object relational approach, many related predictors are included within a single top-level column. .....   NOTE:  These are just EXCERPTS.  Click here to start reading the Oracle Data Mining a Star Schema: Telco Churn Case Study from the beginning.    

    Read the article

  • Doctrine2 ArrayCollection

    - by boosis
    Ok, I have a User entity as follows <?php class User { /** * @var integer * @Id * @Column(type="integer") * @GeneratedValue */ protected $id; /** * @var \Application\Entity\Url[] * @OneToMany(targetEntity="Url", mappedBy="user", cascade={"persist", "remove"}) */ protected $urls; public function __construct() { $this->urls = new \Doctrine\Common\Collections\ArrayCollection(); } public function addUrl($url) { // This is where I have a problem } } Now, what I want to do is check if the User has already the $url in the $urls ArrayCollection before persisting the $url. Now some of the examples I found says we should do something like if (!$this->getUrls()->contains($url)) { // add url } but this doesn't work as this compares the element values. As the $url doesn't have id value yet, this will always fail and $url will be dublicated. So I'd really appreciate if someone could explain how I can add an element to the ArrayCollection without persisting it and avoiding the duplication? Edit I have managed to achive this via $p = function ($key, $element) use ($url) { if ($element->getUrlHash() == $url->getUrlHash()) { return true; } else { return false; } }; But doesn't this still load all urls and then performs the check? I don't think this is efficient as there might be thousands of urls per user.

    Read the article

  • Beginner's guide for rails

    - by piemesons
    Hello friends i need a book/ tutorials for rails without using scoffold. All the books mentioned in the other questions are creating some depot application or etc using scaffold and then explaining things. I believe in the thing that creating big depot is worthless when you are not getting anything. All of my frnds are suggesting me to go for this pragmatic book. look i understand the book is good but i m not getting the proper things. I got the logic cause i m good in php doctrine. asp.net c c++ so i m getting the things but i m not feeling confident. I want to have a another book. Can anybody suggest me some other books. I m saying this cause it really feels good when u create a simple form and insert the values in db and u can retreive those values and MOST IMP you can explain the whole logic of the that small form application instaed of that colorfull Depot application in which things are done with scaffold and u r not getting the thing and u are confused abt the real picture.

    Read the article

  • DATE_FORMAT in DQL symfon2

    - by schurtertom
    I would like to use some MySQL functions such as DATE_FORMAT in my QueryBuilder. I saw this post did not understand totally how I should achieve it: SELECT DISTINCT YEAR Doctrine class SubmissionManuscriptRepository extends EntityRepository { public function findLayoutDoneSubmissions( $fromDate, $endDate, $journals ) { if( true === is_null($fromDate) ) return null; $commQB = $this->createQueryBuilder( 'c' ) ->join('c.submission_logs', 'k') ->select("DATE_FORMAT(k.log_date,'%Y-%m-%d')") ->addSelect('c.journal_id') ->addSelect('COUNT(c.journal_id) AS numArticles'); $commQB->where("k.hash_key = c.hash_key"); $commQB->andWhere("k.log_date >= '$fromDate'"); $commQB->andWhere("k.log_date <= '$endDate'"); if( $journals != null && is_array($journals) && count($journals)>0 ) $commQB->andWhere("c.journal_id in (" . implode(",", $journals) . ")"); $commQB->andWhere("k.new_status = '20'"); $commQB->orderBy("k.log_date", "ASC"); $commQB->groupBy("c.hash_key"); $commQB->addGroupBy("c.journal_id"); $commQB->addGroupBy("DATE_FORMAT(k.log_date,'%Y-%m-%d')"); return $commQB->getQuery()->getResult(); } } Entity SubmissionManuscript /** * MDPI\SusyBundle\Entity\SubmissionManuscript * * @ORM\Entity(repositoryClass="MDPI\SusyBundle\Repository\SubmissionManuscriptRepository") * @ORM\Table(name="submission_manuscript") * @ORM\HasLifecycleCallbacks() */ class SubmissionManuscript { ... /** * @ORM\OneToMany(targetEntity="SubmissionManuscriptLog", mappedBy="submission_manuscript") */ protected $submission_logs; ... } Entity SubmissionManuscriptLog /** * MDPI\SusyBundle\Entity\SubmissionManuscriptLog * * @ORM\Entity(repositoryClass="MDPI\SusyBundle\Repository\SubmissionManuscriptLogRepository") * @ORM\Table(name="submission_manuscript_log") * @ORM\HasLifecycleCallbacks() */ class SubmissionManuscriptLog { ... /** * @ORM\ManyToOne(targetEntity="SubmissionManuscript", inversedBy="submission_logs") * @ORM\JoinColumn(name="hash_key", referencedColumnName="hash_key") */ protected $submission_manuscript; ... } any help I would appreciate a lot. EDIT 1 I have now successfully be able to add the Custom Function DATE_FORMAT. But now if I try with my Group By I get the following Error: [Semantical Error] line 0, col 614 near '(k.logdate,'%Y-%m-%d')': Error: Cannot group by undefined identification variable. Anyone knows about this?

    Read the article

  • How can I get the user object from a service in Symfony2

    - by pogo
    My site is using a third party service for authentication as well as other bits of functionality so I have setup a service that does all the API calls for me and it's this service that I need to be able to access the user object. I've tried injecting the security.context service into my API service but I get a ServiceCircularReferenceException because my user authentication provider references the API service (it has to in order to authenticate the user). So I get a chain of security.context -> authentication provider -> user provider -> API service -> security.context I'm struggling to this of another way of getting the user object and I can't see any obvious way of splitting up this chain. My configs are all defined in config.yml, here are the relevant bits myapp.database: class: Pogo\MyAppBundle\Service\DatabaseService arguments: siteid: %siteid% entityManager: "@doctrine.orm.entity_manager" myapp.apiservice: class: Pogo\MyAppBundle\Service\TicketingService arguments: entityManager: "@myapp.database" myapp.user_provider: class: Pogo\MyAppBundle\Service\APIUserProvider arguments: entityManager: "@myapp.database" ticketingAdapter: "@myapp.apiservice" securityContext: "@security.context" myapp.authenticationprovider: class: Pogo\MyAppBundle\Service\APIAuthenticationProvider arguments: userChecker: "@security.user_checker" encoderFactory: "@security.encoder_factory" userProvider: "@myapp.user_provider" myapp.user_provider is the service that I've defined as my user provider service in security.yml which I presume is how it's being referenced by security.context

    Read the article

  • Go for Zend framework or Django for a modular web application?

    - by dr. squid
    I am using both Zend framework and Django, and they both have they strengths and weakness, but they are both good framworks in their own way. I do want to create a highly modular web application, like this example: modules: Admin cms articles sections ... ... ... I also want all modules to be self contained with all confid and template files. I have been looking into a way to solve this is zend the last days, but adding one omer level to the module setup doesn't feel right. I am sure this could be done, but should I? I have also included Doctrine to my zend application that could give me even more problems in my module setup! When we are talking about Django this is easy to implement (Easy as in concept, not in implementation time or whatever) and a great way to create web apps. But one of the downsides of Django is the web hosing part. There are some web hosts offering Django support, but not that many.. So then I guess the question is what have the most value; rapid modular development versus hosting options! Well, comments are welcome! Thanks

    Read the article

  • unknown exception error in php

    - by fayer
    i wanna catch all exceptions thrown in a script and then check if they have a error code 23000. if they don't i want to rethrow the exception. here is my code: function myException($exception) { /*** If it is a Doctrine Connection Mysql Duplication Exception ***/ if(get_class($exception) === 'Doctrine_Connection_Mysql_Exception' && $exception->getCode() === 23000) { echo "Duplicate entry"; } else { throw $exception; } } set_exception_handler('myException'); $contact = new Contact(); $contact->email = 'peter'; $contact->save(); but i get this error message and i dont know what it means: Fatal error: Exception thrown without a stack frame in Unknown on line 0 i want to be able to rethrow the original error message if it has not the error code 23000. even when i deleted the check errorcode i still get the same message: function myException($exception) { throw $exception; } set_exception_handler('myException'); $contact = new Contact(); $contact->email = 'peter'; $contact->save(); how could i solve this? thanks

    Read the article

  • manyToOne is creating new products

    - by user788721
    I am trying to implement Sylius Cart Bundle, but every time I add a product to the cart, a new product is created. This is probably link to my line: cascade: ["persist", "remove"] In my YAML File: Pharmacie\FrontBundle\Entity\CartItem: type: entity table: app_cart_item manyToOne: produit: targetEntity: Pharmacie\FrontBundle\Entity\Product cascade: ["persist", "remove"] joinColumn: name: product_id referencedColumnName: id But if take it off, I get an error: A new entity was found through the relationship 'Pharmacie\FrontBundle\Entity\CartItem#produit' that was not configured to cascade persist operations for entity: 3test2. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}) According to the doctrine doc, this error occurs when you set a new object. But I am only getting an existing object By ID: $product = $this->getProductRepository()->find($productId); $item->setProduit($product); //this generates the error $item->setUnitPrice(5); //this works fine I don't understand why it's save as a new object. If I use merge instead of persist, I get the same error: A new entity was found through the relationship...

    Read the article

  • Scalable Full Text Search With Per User Result Ordering

    - by jeremy
    What options exist for creating a scalable, full text search with results that need to be sorted on a per user basis? This is for PHP/MySQL (Symfony/Doctrine as well, if relevant). In our case, we have a database of workouts that have been performed by users. The workouts that the user has done before should appear at the top of the results. The more frequently they've done the workout, the higher it should appear in search matches. If it helps, you can assume we know the number of times a user has done a workout in advance. Possible Solutions Sphinx - Use Sphinx to implement full text search, do all the querying and sorting in MySQL. This seems promising (and there's a Symfony Plugin!) but I don't know much about it. Lucene - Use Lucene to perform full text search and put the users' completions into the query. As is suggested in this Stack Overflow thread. Alternatively, use Lucene to retrieve the results, then reorder them in PHP. However, both solutions seem clunky and potentially unscalable as a user may have completed hundreds of workouts. Mysql - No native full text support (InnoDB), so we'd have use LIKE or REGEX, which isn't scalable.

    Read the article

  • Which is the event listener after doSave() in Symfony?

    - by fesja
    Hi, I've been looking at this event-listeners page http://www.doctrine-project.org/documentation/manual/1_1/pl/event-listeners and I'm not sure which is the listener I have to use to make a change after the doSave() method in the BaseModelForm.class.php. // PlaceForm.class.php protected function doSave ( $con = null ) { ... parent::doSave($con); .... // Only for new forms, insert place into the tree if($this->object->level == null){ $parent = Place::getPlace($this->getValue('parent'), Language::getLang()); ... $node = $this->object->getNode(); $method = ($node->isValidNode() ? 'move' : 'insert') . 'AsFirstChildOf'; $node->$method($parent); //calls $this->object->save internally } return; } What I want to do is to make a custom slug with the ancestors' name of that new place. So if I inserting "San Francisco", the slug would be "usa-california-san-francisco" public function postXXXXXX($event) { ... $event->getInvoker()->slug = $slug; } The problem is that I'm inserting a new object with no reference to its parent. After it's saved, I insert it to the tree. So I can't change the slug until then. I think a Transaction listener could work, but I'm use there is a better way I'm not seeing right now. thanks!

    Read the article

  • Symfony form->bind fails

    - by Shawn Craver
    I'm working with a few custom forms, and one of them isn't binding it's values on a POST. I'm using the same logic for each, and only one of them isn't working. Here's the code: public function executeMediaFileUpload(sfWebRequest $request) { $this->form = new MediaFileUploadForm(); if (!$request->isMethod('POST')) $psk = $request->getParameter('psk'); else { $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $this->logMessage('VALUE: ' . $this->form->getValue('version')); $psk = $this->form->getValue('application'); } $this->logMessage('PSK: ' . $psk); $app = Doctrine::getTable('Application')->find(array($psk)); $this->form->setDefault('application', $app->getPsk()); $this->form->setDefault('version', $app->getVersion()->getLast()->getPsk()); On the initial GET, I can see the value passed in via psk getting set as the default for application in the generated HTML, and all the values show up in the POST request in Firebug, but after I bind the form, it still contains no values.

    Read the article

  • Symfony 1.3: Any opinion about this code? Coud be shorter or better?

    - by user248959
    Hi, I need your opinion about this code below. I have a list of messages: each message has a link that change the state of the message (read - non read). In the partial "_message" i have this: <div class="switching_link" id="switching_link_<?php echo $message ?>"> echo include_partial('link_switch_state', array('message' => $message)) </div> In the partial "_link_switch_state" i have this: if((int)$message->getState() == 1) { $string_state_message="non read"; } else { $string_state_message="read"; } echo link_to_remote('Mark as '.$string_state_message, array( 'url' => 'message/switchState?id='.$message->getId(), 'update' => 'switching_link_'.$message, "complete" => "switchClassMessage('$message');", )); And in message/actions/actions.class.php i have this: public function executeSwitchState(sfWebRequest $request) { // searching the message we want to change its state. $this->messages = Doctrine::getTable('Message')->findById($request->getParameter('id')); // changing the state of the message. if($this->messages[0]->getState() == 1) { $this->messages[0]->setState(0); } else { $this->messages[0]->setState(1); } $this->messages[0]->save(); // rendering the partial that shows the link ("Mark as read/non read"). return $this->renderPartial('mensaje/link_switch_state', array( 'message' => $this->messages[0])); } Regards Javi

    Read the article

  • php transform array into multidim array

    - by fverswijver
    So I'm working on a website with Doctrine as ORM and I get the following array back as a result: Array ( [0] => Array ( [c_cat_id] => 1 [c_title] => Programas e projetos [p_menu] => PBA BR 163 [p_page_id] => 1 ) [1] => Array ( [c_cat_id] => 1 [c_title] => Programas e projetos [p_menu] => Outros projetos [p_page_id] => 3 ) ) Is it possible to transform this array (in PHP) to something like this: Array ( [0] => Array ( [c_cat_id] => 1 [c_title] => Programas e projetos [pages] => Array ([p_page_id] => 1 [p_menu] => PBA BR 163, [p_page_id] => 3 [p_menu] => Outros projetos)) Thanks for your help, always eager to learn new ways of doing things and that's why I love StackOverflow ;)

    Read the article

< Previous Page | 12 13 14 15 16 17  | Next Page >