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 $folderid; public $type; public $title; public $priority; public $image; public $url; public $createddate; 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 $userid; public $empid; public $password; public $salt; public $firstname; public $midilename; public $lastname; public $preferredname; public $created; public $email; public $accesslevel; public $inactive; public $updated; public $status; public $hiredate; public $birthdate; public $regularpayratecode;

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($empid,$password) { // Updating a single column $phql = "UPDATE users SET password ='".$password."' ,status='Active' WHERE empid = '".$empid."'"; $this->modelsManager->executeQuery($phql); return 'update'; } public function getUser($empid,$password) { // Updating a single column $phql = "select * from users SET WHERE empid = '".$empid."' 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 ='".$userar['email']."' ,firstname='".$userar['firstname']."', lastname ='".$userar['lastname']."' ,midilename='".$userar['midilename']."', preferredname ='".$userar['preferredname']."' ,birthdate='".$userar['birthdate']."', hiredate ='".$userar['hiredate']."' ,regularpayratecode='".$userar['regularpayratecode']."' WHERE empid = '".$userar['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.



46.8k

Ouch Deepak, maybe next time you could try to post code that hasn't been forwarded to you with all of the ">" symbols. It makes it more difficult by a large margin.