使用Doctrine 1删除记录时出现问题

时间:2011-05-11 19:30:53

标签: php

我正在测试以下代码;它出什么问题了?

<?php

require_once(dirname(__FILE__) . '/lib/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();

class Users extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('users');
        $this->hasColumn('id', 'integer', null, array('primary' => true));
        $this->hasColumn('name', 'string', 255);
    }
}

$conn = Doctrine_Manager::connection('mysql://root:123456@localhost/test');

$users = new Doctrine_Core::getTable('Users');
$user = $users->find(10);
$user->delete();

1 个答案:

答案 0 :(得分:0)

$q = Doctrine_Core::getTable('Users')
->createQuery('u')
->where('u.id = ?', 10);

$user = $q->fetchOne(array(), Doctrine_Core::HYDRATE_RECORD);
$user->delete();