Hola "que tal" ----------------> me lo inesrtaria en bd como: hola /"que tal/".
Os explico un poco como tengo hechas las clases. Tengo una clase principal de la que heredan los demás objetos y en la que están todos los métodos, por lo tanto cuando quiero hacer una nueva clase lo único que tengo que hacer es hacer que herede de esta y sólo 2 métodos, uno que dice la tabla de la bd y otro la relación entre los atributos y el nombre de los campos en la bd. La verdad ahorra mucho trabajo. Os pongo el metodo que inserta y actualiza en bd a ver si veis el problema:
Código PHP:
public function Save() {
if (isset($this->ID)) {
$strQuery = 'UPDATE ' . $this->strTableName . ' SET ';
foreach ($this->arRelationMap as $key => $value) {
eval('$actualVal = &$this->' . $value . ';');
if (array_key_exists($value, $this->arModifiedRelations)) {
$strQuery .= $key . " = :$value, ";
};
}
$strQuery = substr($strQuery, 0, strlen($strQuery)-2);
$strQuery .= ' WHERE id = :eid';
unset($objStatement);
$objStatement = $this->objPDO->prepare($strQuery);
$objStatement->bindValue(':eid', $this->ID, PDO::PARAM_INT);
foreach ($this->arRelationMap as $key => $value) {
eval('$actualVal = &$this->' . $value . ';');
if (array_key_exists($value, $this->arModifiedRelations)) {
if ((is_int($actualVal)) || ($actualVal == NULL)) {
$objStatement->bindValue(':' . $value, $actualVal,
PDO::PARAM_INT);
} else {
$objStatement->bindValue(':' . $value, $actualVal,
PDO::PARAM_STR);
};
};
};
$objStatement->execute();
} else {
$strValueList = "";
$strQuery = 'INSERT INTO ' . $this->strTableName . '(';
foreach ($this->arRelationMap as $key => $value) {
eval('$actualVal = &$this->' . $value . ';');
if (isset($actualVal)) {
if (array_key_exists($value, $this->arModifiedRelations)) {
$strQuery .= $key . ', ';
$strValueList .= ":$value, ";
};
};
}
$strQuery = substr($strQuery, 0, strlen($strQuery) - 2);
$strValueList = substr($strValueList, 0, strlen($strValueList) - 2);
$strQuery .= ") VALUES (";
$strQuery .= $strValueList;
$strQuery .= ")";
unset($objStatement);
$objStatement = $this->objPDO->prepare($strQuery);
foreach ($this->arRelationMap as $key => $value) {
eval('$actualVal = &$this->' . $value . ';');
if (isset($actualVal)) {
if (array_key_exists($value, $this->arModifiedRelations)) {
if ((is_int($actualVal)) || ($actualVal == NULL)) {
$objStatement->bindValue(':' . $value, $actualVal, PDO::PARAM_INT);
} else {
$objStatement->bindValue(':' . $value, $actualVal, PDO::PARAM_STR);
}
}
}
}
$objStatement->execute();
$this->ID = $this->objPDO->lastInsertId($this->strTableName . "_id_seq");
}
}
Alguien me puede decir que puedo hacer para solucionarlo. Si quieren comprobar como ocurre el fallo metanse en www.diacarmona.es y lo podrán ver en cualquier titulo de noticia o comentario, y la verdad que es bastante feo a la vista.