We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model Could not be loaded issue came for some models

For some models my phql queries NOT working properly

<?php use Phalcon\Mvc\Model; class DocLinks extends Model { public $id; public $folder_id; public $type; public $title; public $priority; public $image; public $url; public $created_date; public $updated_date;

public function initialize() {
    $this->setSource("doc_links");
}
public function getDocs() {
    // Updating a single column
    $phql = "select * from doc_links  WHERE  type='DOC'";
    $qry = $this->modelsManager->createQuery($phql);
    //echo 'sdfsfasdf'; exit;
    return $qry->execute();
}

}

BUT IN MANY IT IS WORKING

<?php use Phalcon\Mvc\Model; class users extends Model { public $user_id; public $emp_id; public $password; public $salt; public $first_name; public $midile_name; public $last_name; public $preferred_name; public $created; public $email; public $access_level; public $inactive; public $updated; public $status; public $hire_date; public $birth_date; public $regular_pay_rate_code;

public function initialize() { $this->setSource("users"); }

public function getFullName() {
    return $this->first_name . ' ' . $this->last_name;
}
public function getFullNameLastFirst() {
    return  $this->last_name . ', '. $this->first_name;
}

public function getEmployeeId() { return $this->emp_id; } public function testMod() { return 'gdfgf'; }

public function updateUser($emp_id,$password) { // Updating a single column $phql = "UPDATE users SET password ='".$password."' ,status='Active' WHERE emp_id = '".$emp_id."'"; $this->modelsManager->executeQuery($phql); return 'update'; } public function getUser($emp_id,$password) { // Updating a single column $phql = "select * from users SET WHERE emp_id = '".$emp_id."' and status='Active'"; $this->modelsManager->executeQuery($phql); return 'update'; } public function updatePro($user_ar) {

// Updating a single column $phql = "UPDATE users SET status='Active' ,email ='".$user_ar['email']."' ,first_name='".$user_ar['first_name']."', last_name ='".$user_ar['last_name']."' ,midile_name='".$user_ar['midile_name']."', preferred_name ='".$user_ar['preferred_name']."' ,birth_date='".$user_ar['birth_date']."', hire_date ='".$user_ar['hire_date']."' ,regular_pay_rate_code='".$user_ar['regular_pay_rate_code']."' WHERE emp_id = '".$user_ar['id']."'"; $this->modelsManager->executeQuery($phql); return 'update'; } }

And showing issue of models could not be loaded

I think there is a foreign key constraint thats why this is comes

Show exactly exception which you have.