Hi!
I want to have from my database one specific entry. The application time entry. Semester is the name of my table and active is another column.
I’m trying this code:
$sqlQuery = $this->sql->select()->from('semester', 'applicationTime')->where('active = ?',1);
$sqlStmt = $this->sql->prepareStatementForSqlObject($sqlQuery);
return $sqlStmt->execute();
Unfortunately I’m getting thie error message:
Since this object was created with a table and/or schema in the constructor, it is read only.
I hope you can help me. Thank you!
Thank you for your response, but it stil doesn’t work
Unfortunately, I can only guess, as the context is missing. For example, how this->sql
is created and why a second parameter is used for the method from
.
Please try the following:
$sqlQuery = $this->sql->select('semester')->where('active = ?',1);
This will create a new Laminas\Db\Sql\Select
object for the table semester
otherwise the Laminas\Db\Sql\Sql
object uses the table that was specified when it was created:
$sql = new Laminas\Db\Sql\Sql($adapter, 'tableName');
https://docs.laminas.dev/laminas-db/sql/#quick-start