# Database Query Error

**URL:** <https://discourse.laminas.dev/t/database-query-error/2088>\
**Category:** Components & MVC\
**Tags:** laminas-db\
**Created:** [February 2, 2021, 4:51pm UTC](https://discourse.laminas.dev/t/database-query-error/2088 "2021-02-02T16:51:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panstone](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@Panstone](https://discourse.laminas.dev/u/Panstone)\
**Post date:** [February 2, 2021, 4:51pm UTC](https://discourse.laminas.dev/t/database-query-error/2088/1 "2021-02-02T16:51:43Z")

</div>

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:

```php
$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!

---

<div class="post-metadata">

**Author:** ![Panstone](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@Panstone](https://discourse.laminas.dev/u/Panstone)\
**Post date:** [February 3, 2021, 10:21am UTC](https://discourse.laminas.dev/t/database-query-error/2088/3 "2021-02-03T10:21:22Z")

</div>

Thank you for your response, but it stil doesn’t work ☹

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [February 3, 2021, 2:38pm UTC](https://discourse.laminas.dev/t/database-query-error/2088/4 "2021-02-03T14:38:05Z")

</div>

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:

```php
$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:

```php
$sql = new Laminas\Db\Sql\Sql($adapter, 'tableName');

```

[https://docs.laminas.dev/laminas-db/sql/#quick-start](https://docs.laminas.dev/laminas-db/sql/#quick-start)
