After setting up the foreign key constraints on database, I cannot use the function of CASCADE.

Model 1: ```class Teacher extends \Phalcon\Mvc\Model { public $id; public $name; public function initialize() { $this->hasMany( "id", "students", "teacherid" 'foreignKey' => array( 'action' => Relation::ACTIONCASCADE ) ); } }``` Model 2: ```class Students extends \Phalcon\Mvc\Model { public $id; public $teacherid; public $name; public function initialize() { $this->belongsTo( "teacherid", "teacher", "id", array( "foreignKey" => true ) ); } } $teacher = Teacher::findFirst("id=1"); $teacher->delete();``` SQLSTATE[HY000]: General error: 2292 OCIStmtExecute: ORA-02292: integrity constraint (TEST.FKSTUDENTTEACHERID) violated - child record found (/root/rpmbuild/BUILD/php-5.5.1/ext/pdooci/oci_statement.c:148)

I changed the order of the steps of deletion and then I can use CASCADE. Is bug? /** * Check if there is virtual foreign keys with cascade action */ if (PHALCONGLOBAL(orm).virtualforeign_keys) {

            phalcon_call_method(check_foreign_keys, this_ptr, "_checkforeignkeysreversecascade");
            if (PHALCON_IS_FALSE(check_foreign_keys)) {

     * Do the deletion
    phalcon_call_method_p4(success, write_connection, "delete", table, delete_conditions, values, bind_types);

    if (PHALCON_GLOBAL(orm).events) {
            if (zend_is_true(success)) {
                    ZVAL_STRING(event_name, "afterDelete", 1);
                    phalcon_call_method_p1_noret(this_ptr, "fireevent", event_name);

need to delete child record before parent record i think it is a bug


First, It deletes the students, then it deletes the teacher, maybe it is not finding the students. Could you please set an events manager up in the connection to see what SQL comments are being sent to the database server?



i'm getting the same problem too: the CASCADE in model initialize is ignored so i've to currently delete children records manually. This seems a bug ( regression since no problems were found on 1.2.3 ).


same problem here