Here is my database schema for my MySQL database:
create table noticia
(
id int,
imagen varchar(255),
fecha datetime,
titulo varchar(255),
url varchar(255),
descripcion varchar(255),
contenido text
)
I'm using RedBeanPHP as my ORM to save the information to a database. Here is where I'm scraping and parsing the dates to a DateTime
object as per the documentation.
foreach ($element->find('span.fechanoticia') as $fecha) {
$tmp = str_replace("/", "-", $fecha->innertext);
print_r($tmp);
$dateFoo = new DateTime($tmp);
echo $dateFoo->format('Y-m-d H:i:s');
$newItem->set_fechanoticia($dateFoo);
}
The $tmp
variable this value for example:
05-09-2012
The echo
call to format returns:
2012-09-05 00:00:00
Everything is peachy, and working.
However when I try to save it to the database using RedBeanPHP I get this error:
Fatal error: Uncaught exception 'RedBean_Exception_Security' with message 'Invalid Bean: property fecha ' in C:\xampp\htdocs\blog-uvmb.php:4880 Stack trace: #0 C:\xampp\htdocs\blog-uvmb.php(5108): RedBean_OODB->check(Object(RedBean_OODBBean)) #1 C:\xampp\htdocs\blog-uvmb.php(5082): RedBean_OODB->storeBean(Object(RedBean_OODBBean)) #2 C:\xampp\htdocs\blog-uvmb.php(7005): RedBean_OODB->store(Object(RedBean_OODBBean)) #3 C:\xampp\htdocs\blog-uvm\index.php(60): RedBean_Facade::store(Object(RedBean_OODBBean)) #4 {main} thrown in C:\xampp\htdocs\blog-uvmb.php on line 4880
Can RedBeanPHP not handle datetime objects?