推进从表中选择一列

Ama*_*nut 2 mysql database orm propel

我正在使用Propel 2,我希望能够在给定的表中选择一列的值,等效的原始SQL查询如下所示:

select author_id from book_authors WHERE book_id = 111;
Run Code Online (Sandbox Code Playgroud)

如果我写

BookAuthorsQuery::create()->findByAuthorId(111);
Run Code Online (Sandbox Code Playgroud)

我将得到一个包含该表所有字段的数组对象,但我只是一个包含所选列的值的数组.

Qin*_*iso 9

试试这个:

BookAuthorsQuery::create()->select(array('author_id'))->findByBookId(111);
Run Code Online (Sandbox Code Playgroud)

->select(array('author_id'))在推进的查询会推动你想从你的表中选择字段的数组.