Problems With Deletion

I am trying to do something similar to the results of this post (, but I am having troubles making this work, as well as just getting deletion to work normally.

```foreach($deletable as $single) { $user = UserProjects::findFirst(array( 'conditions' => 'userid=?0 and projectid=?1 and is_stakeholder=1', 'bind' => array( $single, $project->id ) ));



This throws me a PDOException. I ran some code to show me the queries being generated, and for some reason I am getting: DELETE FROM users_projects WHERE. There is nothing getting appended to the end of the query.

I have ensured that I am getting a result from the initial findFirst, but, after that, nothing happens. Any ideas? I'm on Phalcon 0.9.1.


Does UserProjects have a primary key?


It does not. It is a pivot table. Sorry. Forgot to mention that.


Since the SQL is dinamically generated, the ORM cannot delete a record if a primary key is not available.


So, I take there is no way to delete from pivot tables, aside from creating the query yourself? If that's the case, that's fine.


You can do something like:

$user->getConnection->delete("user_projects", "user_id=? and project_id=? and is_stakeholder=1", array($singe, $project->id));