Closed tashemi closed 11 years ago
Could you try the following code and report back the results?
$event = ORM::for_table('events')->find_one($eventId);
var_dump($event);
Incidentally if you are using find_one()
and supplying it an ID then you don't need the where()
in your query as the ID is already a unique reference/primary key to a certain record.
Table events
contains events created by different users. I use where()
be sure that logged user tries delete his own event and not somebody's else.
var_dump
results:
object(Idiorm)#29 (22) {
["_connection_name":protected]=>
string(7) "default"
["_table_name":protected]=>
string(6) "events"
["_table_alias":protected]=>
NULL
["_values":protected]=>
array(0) {
}
["_result_columns":protected]=>
array(1) {
[0]=>
string(1) "*"
}
["_using_default_result_columns":protected]=>
bool(true)
["_join_sources":protected]=>
array(0) {
}
["_distinct":protected]=>
bool(false)
["_is_raw_query":protected]=>
bool(false)
["_raw_query":protected]=>
string(0) ""
["_raw_parameters":protected]=>
array(0) {
}
["_where_conditions":protected]=>
array(0) {
}
["_limit":protected]=>
NULL
["_offset":protected]=>
NULL
["_order_by":protected]=>
array(0) {
}
["_group_by":protected]=>
array(0) {
}
["_having_conditions":protected]=>
array(0) {
}
["_data":protected]=>
array(8) {
["Id"]=>
string(1) "1"
["AccountId"]=>
string(1) "2"
["Caption"]=>
string(10) "Coffee cup"
["Date"]=>
string(10) "2013-10-02"
["Time"]=>
string(5) "08:30"
["Place"]=>
string(4) "Kyiv"
["Details"]=>
string(47) "Morning coffee with nice talking about Universe"
["Coords"]=>
NULL
}
["_dirty_fields":protected]=>
array(0) {
}
["_expr_fields":protected]=>
array(0) {
}
["_is_new":protected]=>
bool(false)
["_instance_id_column":protected]=>
NULL
}
I can see your problem. Your ID column is not the same as that expected by Idiorm. You are using Id
whereas Idiorm expects id
(note all lower case). So you have a few choices:
id
instead of Id
use_id_column()
- see PHPDoc at: https://github.com/j4mie/idiorm/blob/a1f5dc4029526f0d2605bce4a6f1f4c562ce9aa9/idiorm.php#L552@treffynnon thanks, now I see difference
I try to delete a row using next code:
Idiorm generates next SQL
Why can it happen?