我正在测试以下代码;它出什么问题了?
<?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();
答案 0 :(得分:0)
$q = Doctrine_Core::getTable('Users')
->createQuery('u')
->where('u.id = ?', 10);
$user = $q->fetchOne(array(), Doctrine_Core::HYDRATE_RECORD);
$user->delete();