我正在尝试执行此DQL:
$q = Doctrine_Query::create()
->select('*');
->from('Clientes c');
$retorno = $q->execute();
My BaseClientes.php:
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('Clientes', 'padrao');
/**
* BaseClientes
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $pk_clientes
* @property string $txt_nome
* @property timestamp $ts_cadastro
* @property string $txt_diretorio
* @property Doctrine_Collection $Upload
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseClientes extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('clientes');
$this->hasColumn('pk_clientes', 'integer', 4, array(
'type' => 'integer',
'length' => 4,
'fixed' => false,
'unsigned' => false,
'primary' => true,
'autoincrement' => true,
));
$this->hasColumn('txt_nome', 'string', 255, array(
'type' => 'string',
'length' => 255,
'fixed' => false,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('ts_cadastro', 'timestamp', null, array(
'type' => 'timestamp',
'fixed' => false,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('txt_diretorio', 'string', 255, array(
'type' => 'string',
'length' => 255,
'fixed' => false,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
}
public function setUp()
{
parent::setUp();
$this->hasMany('Upload', array(
'local' => 'pk_clientes',
'foreign' => 'fk_clientes'));
}
}
我的表SQL:
CREATE TABLE `organizer`.`clientes` (
`pk_clientes` int(11) NOT NULL AUTO_INCREMENT,
`txt_nome` varchar(255) NOT NULL,
`ts_cadastro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`txt_diretorio` varchar(255) NOT NULL,
PRIMARY KEY (`pk_clientes`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC
当我执行这个DQL时,它会返回给我:
Fatal error: Uncaught exception 'Doctrine_Record_UnknownPropertyException' with message 'Unknown record property / related component "clientes" on "Clientes"' in
/var/www/organizer/lib/php/doctrine/lib/Doctrine/Record/Filter/Standard.php:55 Stack trace: #0 /var/www/organizer/lib/php/doctrine/lib/Doctrine/Record.php(1382):
Doctrine_Record_Filter_Standard->filterGet(Object(Clientes), 'clientes') #1 /var/www/organizer/lib/php/doctrine/lib/Doctrine/Record.php(1337): Doctrine_Record->_get
('clientes', true) #2 /var/www/organizer/lib/php/doctrine/lib/Doctrine/Access.php(117): Doctrine_Record->get('clientes') #3 /var/www/organizer/lib/php/forger.php
(387): Doctrine_Access->offsetGet('clientes') #4 /var/www/organizer/app/clientes/model.php(20): forger->Table(Array) #5 /var/www/organizer/app/clientes/controller.php
(5): require_once('/var/www/organi...') #6 /var/www/organizer/web/index.php(9): require_once('/var/www/organi...') #7 {main} thrown in /var/www/organizer/lib/php/
doctrine/lib/Doctrine/Record/Filter/Standard.php on line 55
我真的不知道发生了什么,我的系统和工作的其他文件也有同样的情况。
请有人帮助我....
OBS:对不起,我的英文不好,我是巴西人。答案 0 :(得分:0)
感谢您的回答,但我发现了“错误”......
我需要的只是恢复数组中的数据,因此我在Google中搜索并找到了:
$con = Doctrine_Manager::getInstance()->connection();
$res = $con->execute("SELECT * FROM clientes;", array(1));
$retorno = $res->fetchAll();
这解决了我的问题因为我试图使用$ q-&gt; execute()作为数组返回...
PS:抱歉拼错xD ......