php - Class not found -


i made research results not related problem : have model associated table contains underscore.

<?php  use phalcon\mvc\model; use phalcon\mvc\model\query;  class tableclient extends model {      public function getsource()     {         return "table_client";     }      function lireparcritere($critere) {          $ssql = "                 select c.table_code,s.salle_code,s.salle_lib,c.table_lib,c.table_nb_couvert,c.table_comment                  table_client c inner join salle s on s.salle_code = c.salle_code                 1 = 1 ";          if(isset($critere["table_code"]) && $critere["table_code"] != "") {             $ssql .= "and c.table_code = '" . $critere["table_code"] . "' ";             }          $query = new query($ssql,$this->getdi());          $ret = $query->execute();          return $ret;      }      function ajouter($tab) {         $champs= "";         $value = "";         $separateur ="";          foreach ($tab $k => $v){             $champs .= $separateur . $k;             $value .= $separateur . "'" . $v . "'";             $separateur = ",";         }         $champs = '('.$champs.')';         $value = '('.$value.')';         $ssql = "                 insert table_client $champs                 values $value                 ";         $query = new query($ssql,$this->getdi());         $ret = $query->execute();     }      function modifier($tab) {          $setcolumns = "";         $separateur = "";          foreach ($tab $k => $v){             if ($k == 'table_code')                 continue;             $setcolumns .= $separateur . 'table_client.' . $k . " = '" . $v . "'";             $separateur = ",";         }          $ssql = "update table_client set ".$setcolumns." table_client.table_code = '".$tab['table_code']."'";          $query = new query($ssql, $this->getdi());         $ret = $query->execute();     }      function supprimer($tab) {         $ssql = "delete table_client table_client.table_code = '".$tab['table_code']."'";         $query = new query($ssql, $this->getdi());         $ret = $query->execute();     } }  ?> 

inside controller want call method of model :

public function modifieraction($id){         $this->view->action_form = '../modifierexec';         $this->view->titre = 'modification de table';         $critere = array();         $critere["table_code"] = $id;         $this->view->data = tableclient::lireparcritere($critere); // here call of model's method         return $this->view->pick("table/table");     } 

at runtime class not found error ! how fix ?

  1. check class class_exists() function
  2. check phalcon autoloader config. make sure put in autoloader config class/directory/namespace/
  3. you can check class availability in constroller:

    foreach (spl_autoload_functions() $function) {     foreach ($function $object) {         if (!$object instanceof \phalcon\loader) {             continue;         }          var_dump($object->getnamespaces());         var_dump($object->getcheckedpath());         var_dump($object->getdirs());         var_dump($object->getclasses());         var_dump($object->getfoundpath());     } }  die; 

edit

  1. \phalcon\mvc\model\query uses phql, not sql. in function lireparcritere($critere) use from \fully\qualified\class\name instead from table_client
  2. for tests use $client = new tableclient; $client->lireparcritere($critere); instead tableclient::lireparcritere($critere);

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -