Closed Mangulomx closed 9 years ago
Is $idempleado the result of an Idiorm query? If so you need to $idempleado->id(); instead. On 16 Dec 2014 18:51, "Miguel Angulo Martínez" notifications@github.com wrote:
I´ve one error idiorm, but I don´t know if could be the date?
$insertOrder = ORM::for_table('pedido')->create(); $insertOrder->fechapedido = date('Y/m/d'); $insertOrder->estado = 1; $insertOrder->empleado_id = $idempleado; $insertOrder->proveedor_id = $_SESSION['idproveedor']; $insertOrder->save(); Message: Object of class ORM could not be converted to string File: C:\wamp\www\viver\vendor\j4mie\idiorm\idiorm.php Line: 413
the line 413 is:
protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION) { self::_log_query($query, $parameters, $connection_name); $statement = self::$_db[$connection_name]->prepare($query);
self::$_last_statement = $statement; return $statement->execute($parameters); }
— Reply to this email directly or view it on GitHub https://github.com/j4mie/idiorm/issues/254.
I make a var_dump($idempleado);die() I get
object(ORM)[35] protected '_connection_name' => string 'default' (length=7)
protected '_table_name' => string 'empleado' (length=8)
protected '_table_alias' => null protected '_values' => array (size=0)
empty protected '_result_columns' => array (size=1) 0 => string '*' (length=1)
protected '_using_default_result_columns' => boolean true
protected '_join_sources' => array (size=0)
empty protected '_distinct' => boolean false protected '_is_raw_query' => boolean false protected '_raw_query' => string '' (length=0) protected '_raw_parameters' => array (size=0) empty protected '_where_conditions' => array (size=0) empty protected '_limit' => null protected '_offset' => null protected '_order_by' => array (size=0) empty protected '_group_by' => array (size=0) empty protected '_having_conditions' => array (size=0) empty protected '_data' => array (size=1) 'id' => string '4' (length=1) protected '_dirty_fields' => array (size=0) empty protected '_expr_fields' => array (size=0) empty protected '_is_new' => boolean false protected '_instance_id_column' => null
My query is $idempleado = ORM::for_table('empleado')->select('id')
where('usuario_idusuario',$_SESSION['user_id'])->find_one();
I already assign id in my query
I don´t understand
CREATE TABLE IF NOT EXISTS `empleado` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
......
You can't assign idiorm instance to db field. See previous comment for fix. On 16 Dec 2014 19:31, "Miguel Angulo Martínez" notifications@github.com wrote:
CREATE TABLE IF NOT EXISTS
empleado
(id
int(11) UNSIGNED NOT NULL AUTO_INCREMENT, ......— Reply to this email directly or view it on GitHub https://github.com/j4mie/idiorm/issues/254#issuecomment-67217163.
ok thanks.
I´ve one error idiorm, but I don´t know if could be the date?
$insertOrder = ORM::for_table('pedido')->create(); $insertOrder->fechapedido = date('Y/m/d'); $insertOrder->estado = 1; $insertOrder->empleado_id = $idempleado; $insertOrder->proveedor_id = $_SESSION['idproveedor']; $insertOrder->save(); Message: Object of class ORM could not be converted to string File: C:\wamp\www\viver\vendor\j4mie\idiorm\idiorm.php Line: 413
the line 413 is:
protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION) { self::_log_query($query, $parameters, $connection_name); $statement = self::$_db[$connection_name]->prepare($query);