0
私はさまざまな可能性を試しましたが、何もうまくいかず、チュートリアルでも例が見つかりませんでした。私は与えられたファイル名の最後のインポートを取得したいので、ISTは、SQLのようでなければなりません私のモデルの最後のレコードセットを選択するための構文
public function getlastImport($filename)
{
//$id = (int) $id;
$rowset = $this->tableGateway->select(['Path' => $filename]);
$row = $rowset->current();
if (! $row) {
throw new RuntimeException(sprintf(
'Could not find row with identifier %d',
$id
));
}
return $row;
}
:
select max(ID) from table where filename = $filename;
しかし、どのようになります
私は私のmodelclassのメソッドを持っていますこの場合の正しい構文ですか?これはあなたを助けるでしょう
public function getlastImport($filename)
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('id', 'filename', 'label'));
$select->where(array('filename' => $filename));
$select->order("id DESC");
$select->limit(1);
$result = $this->tableGateway->selectWith($select);
$row = $result->current();
if (! $row) {
throw new RuntimeException(sprintf(
'Could not find row with identifier %d',
$id
));
}
return $row;
}
希望は、あなたのモデルで、次のよう
質問は、私のモデルに書き込む方法でした。 –
ちょうど編集されたコード!それがあなたのために働くかどうか私達にお知らせください! – unclexo
それは働いて、構文fprのおかげで、私はrowfunction maxを実装するために探していた、このistかなりeasiert –