# SQLSTATE\[HY000\]: General error: 1615 Prepared statement needs to be re-prepared

**URL:** <https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591>\
**Category:** PHPRad Classic\
**Created:** [June 10, 2023, 5:15pm UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591 "2023-06-10T17:15:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendryres](https://forum.radsystems.io/user_avatar/forum.radsystems.io/hendryres/32/1109_2.png) [@hendryres](https://forum.radsystems.io/u/hendryres)\
**Post date:** [June 10, 2023, 5:15pm UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/1 "2023-06-10T17:15:12Z")

</div>

Hi everyone, I have a database view, and it will display on the page list, but the error message appears SQLSTATE[HY000]: General error: 1615 Prepared statement needs to be re-prepared.  
How to solve it?

 ![SQLSTATEHY000](https://forum.radsystems.io/uploads/default/original/1X/64ee80f49efffa10aa27d0b29e5d4e2630f8a0b0.png)

---

<div class="post-metadata">

**Author:** ![willvin](https://forum.radsystems.io/user_avatar/forum.radsystems.io/willvin/32/7_2.png) [@willvin](https://forum.radsystems.io/u/willvin)\
**Post date:** [June 10, 2023, 11:07pm UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/2 "2023-06-10T23:07:37Z")

</div>

Take a look at this solution given here if it helps. [php - Laravel: General error: 1615 Prepared statement needs to be re-prepared - Stack Overflow](https://stackoverflow.com/questions/31957441/laravel-general-error-1615-prepared-statement-needs-to-be-re-prepared)

---

<div class="post-metadata">

**Author:** ![hendryres](https://forum.radsystems.io/user_avatar/forum.radsystems.io/hendryres/32/1109_2.png) [@hendryres](https://forum.radsystems.io/u/hendryres)\
**Post date:** [June 11, 2023, 12:57am UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/3 "2023-06-11T00:57:21Z")

</div>

I don’t know which method to use in the forum you shared. Is it by adding “\PDO::ATTR\_EMULATE\_PREPARES =\> true” (any repercussions to be accepted?) or by “SET GLOBAL table\_definition\_cache = 1024” or even by “protected $primaryKey = ‘id’;”(how can it be from database views). Please tell me?

---

<div class="post-metadata">

**Author:** ![willvin](https://forum.radsystems.io/user_avatar/forum.radsystems.io/willvin/32/7_2.png) [@willvin](https://forum.radsystems.io/u/willvin)\
**Post date:** [June 19, 2023, 8:06am UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/4 "2023-06-19T08:06:04Z")

</div>

The issue with how the database view query has been written, the best option would be to rewrite the query. .“\PDO::ATTR\_EMULATE\_PREPARES =\> true” is more like a bypass. What the above does is escape query parameter values on the PDO library with strings instead of on the MySQL server using the binary protocol.

---

<div class="post-metadata">

**Author:** ![hendryres](https://forum.radsystems.io/user_avatar/forum.radsystems.io/hendryres/32/1109_2.png) [@hendryres](https://forum.radsystems.io/u/hendryres)\
**Post date:** [June 19, 2023, 8:39am UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/5 "2023-06-19T08:39:15Z")

</div>

I will try to implement it, thanks

---

<div class="post-metadata">

**Author:** ![usmraf786](https://forum.radsystems.io/user_avatar/forum.radsystems.io/usmraf786/32/1018_2.png) [@usmraf786](https://forum.radsystems.io/u/usmraf786)\
**Post date:** [October 7, 2023, 7:58pm UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/6 "2023-10-07T19:58:04Z")

</div>

Below is proper solution to solve this issue:  
If you are using views in RadSystems and facing below error:  
sqlstate[hy000]: general error: 1615 prepared statement needs to be re-prepared (sql: select count(\*) as aggregate

Add below code in php-laravel-api\config\Database.php file  
‘options’ =\> [  
\PDO::ATTR\_EMULATE\_PREPARES =\> true  
],

Note: View will give error always after Publish Project with Sync Database.  
To solve it:  
Restart MySQL  
And then Publish Project again, View pages will work.

---

<div class="post-metadata">

**Author:** ![usmraf786](https://forum.radsystems.io/user_avatar/forum.radsystems.io/usmraf786/32/1018_2.png) [@usmraf786](https://forum.radsystems.io/u/usmraf786)\
**Post date:** [October 7, 2023, 8:02pm UTC](https://forum.radsystems.io/t/sqlstate-hy000-general-error-1615-prepared-statement-needs-to-be-re-prepared/1591/8 "2023-10-07T20:02:05Z")

</div>

It will solve the issue.

> [@RadSystems 8.2.3 sqlstate\[hy000\]: general error: 1615 using View](https://forum.radsystems.io/t/radsystems-8-2-3-sqlstate-hy000-general-error-1615-using-view/1769):
>
> If you are using views in RadSystems and facing below error: sqlstate[hy000]: general error: 1615 prepared statement needs to be re-prepared (sql: select count(\*) as aggregate Add below code in php-laravel-api\config\Database.php file ‘options’ =\> [\PDO::ATTR\_EMULATE\_PREPARES =\> true], Note: View will give error always after Publish Project with Sync Database. To solve it: Restart MySQL And then Publish Project again, View pages will work.
