Incorrect data format using Redbean PHP and date - stored as VARCHAR (255)

I am connecting to MySQL with Redbean PHP, and dates and date_deux go through varchar (255).
I assume that by default I work in liquid mode. How can I fix the problem?

require('rb.php'); R::setup('my connection info',$username, $password); $book = R::dispense( 'book' ); $book->title = 'Boost development with RedBeanPHP'; $book->author = 'Charles Xavier'; $book->date = '2010-07-08'; $book->date_deux = '08/07/2010'; $id = R::store($book); echo $id; 

UPDATE:
I assume I'm looking forward to how to do this before version 3.0? The documentation does not indicate what to do before version 3.0.

0
source share
1 answer

In versions of RedBeanPHP older than 3, you can use the optimizer: http://www.redbeanphp.com/extra/optimizer If necessary, it basically changes the columns.

You must connect the optimizer yourself as a listener. Since I saw people struggling with this, I deleted this system and replaced it with a more native approach. Now you can simply assign dates or dates to dates in SQL format, and the column will be created using the correct data type. However, if the column is already used to store other data, the column will not change (this is necessary to save the data already in the column).

+1
source

Source: https://habr.com/ru/post/903485/


All Articles