1

I am using symfony framework for my project, but many time i'm very confused to write mysql query in doctrine mode, so, please suggest me how to write custom query in symfony, like

SELECT * FROM USER WHERE A.ID = 'X3B8882'
2
  • Your answer is given at stackoverflow.com/questions/5324960/… Commented Sep 8, 2011 at 6:32
  • Are you talking about Symfony-2.0 or any previous versions? Commented Sep 8, 2011 at 6:40

2 Answers 2

2

Your sql is invalid, but assuming A is a reference to the user table:

$user = Doctrine_Query::create()
  ->from("User a")
  ->where("a.id = ?", "X3B8882")
  ->fetchOne();

or alternatively

$user = UserTable::getInstance()->findOneById("X3B8882");

This is one of the most basic queries, so I highly recommend you read the documentation available on doctrine's homepage.

Sign up to request clarification or add additional context in comments.

Comments

1
$query="SELECT * FROM USER WHERE A.ID = 'X3B8882'"    

$conn = Doctrine_Manager::getInstance()->connection();
    $stmt = $conn->prepare($query);
    $stmt->execute();
    while ($row = $stmt->fetch()) {
        $results[] = $row['sm_mnuitem_webpage_url'] ;

    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.