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