Column 'ROWCOUNT' doesn't make part of the column map

I add this function to my model

public function validation()
{
  $this->validate(new Uniqueness(array(
      "field"   => "CONT_CEDULA",
      "message" => "Value of field 'email' is already present in another record"
  )));
  if ($this->validationHasFailed() == true) {
      return false;
  }
}

I have this error

Column 'ROWCOUNT' doesn't make part of the column map


763

Can you show me your query (database)?

edited Jun '16

This "CONTCEDULA" should be the name of the column which has to be unique. Is email column in your DB named "CONTCEDULA" ?

edited Jun '16

You have to show us your query + database structure as @fgomes asked.

Also show us your columnMap() method if you used one in your model.



34.2k

Yes, I had already done that but in the Apache2 log shows me the following error

[Thu Jun 16 00:19:20.796813 2016] [:error] [pid 1978] [client 127.0.0.1:24238] PHP Catchable fatal error:  Argument 1 passed to Phalcon\\Mvc\\Model::validate() must implement interface Phalcon\\ValidationInterface, instance of Phalcon\\Mvc\\Model\\Validator\\Uniqueness given in /var/www/html/tesis/app/models/SpmContacto.php on line 300, referer: http://localhost/tesis/spm_contacto/new

This looks like version problem to me. Which Phalcon version are you using? Can you read here and perhaps try with the new Validation service.

https://blog.phalconphp.com/post/phalcon-2-1-beta-released



34.2k

Hello, I had already made this change in my model

use Phalcon\Validation;
use Phalcon\Validation\Validator\Email as EmailValidator;
use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator;

 public function validation()
  {
  $this->validate(
  new UniquenessValidator(
  [
  'field'   => 'CONT_CEDULA',
  'message' => 'Sorry, That username is already taken',
  ]
  )
  );

  if ($this->validationHasFailed() == true) {
  return false;
  }
  }

But the result is

[Thu Jun 16 10:46:38.761135 2016] [:error] [pid 9235] [client 127.0.0.1:25166] PHP Catchable fatal error:  Argument 1 passed to Phalcon\\Mvc\\Model::validate() must implement interface Phalcon\\ValidationInterface, instance of Phalcon\\Validation\\Validator\\Uniqueness given in /var/www/html/tesis/app/models/SpmContacto.php on line 300, referer: http://localhost/tesis/spm_contacto/new


763

Please, paste your full code. (MODEL)



34.2k
edited 29d ago
<?php

    use Phalcon\Validation;
    use Phalcon\Http\Request;
    use Phalcon\Validation\Validator\Email as EmailValidator;
    use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator;

    class SpmContacto extends \Phalcon\Mvc\Model {

    public $CONT_CODIGO;
    public $CONT_CEDULA;
    public $CONT_RUCIDE;
    public $CONT_NOMBRE;
    public $CON_ESTADO;
    public $CONT_TELEFO;
    public $CONT_DIRECC;
    public $CONT_AREA;
    public $CONT_CARGO;
    public $CONT_TIPOXX;
    public $CONT_EMAIL;
    public $CONT_USUARIO;
    public $CONT_CLAVE;
    public $CONT_CLAVEE;
    public $CONT_FECNACI;
    public $CONT_FECINSC;
    public $CONT_TIPOCODIGO;

    /**
     * Initialize method for model.
     */
    public function initialize() {
        $this->setSchema("SPOLS");
        $this->hasMany('CONT_CODIGO', 'SPMREFERENCIA', 'CONT_CODIGO', array('alias' => 'SPMREFERENCIA'));
        $this->hasMany('CONT_CODIGO', 'SPTDETALLE', 'CONT_CODIGO', array('alias' => 'SPTDETALLE'));
        $this->hasMany('CONT_CODIGO', 'SPTENCABEZADO', 'CONT_CODIGO', array('alias' => 'SPTENCABEZADO'));

        $this->keepSnapshots(true);

    }

    public function columnMap()  { 
         return array(  'CONT_CODIGO' => 'CONT_CODIGO', 
                      'CONT_CEDULA' => 'CONT_CEDULA', 
                      'CONT_RUCIDE' => 'CONT_RUCIDE', 
                      'CONT_NOMBRE' => 'CONT_NOMBRE', 
                      'CON_ESTADO' => 'CON_ESTADO', 
                      'CONT_TELEFO' => 'CONT_TELEFO', 
                      'CONT_DIRECC' => 'CONT_DIRECC', 
                      'CONT_AREA' => 'CONT_AREA', 
                      'CONT_CARGO' => 'CONT_CARGO', 
                      'CONT_TIPOXX' => 'CONT_TIPOXX', 
                      'CONT_EMAIL' => 'CONT_EMAIL', 
                      'CONT_USUARIO' => 'CONT_USUARIO', 
                      'CONT_CLAVE' => 'CONT_CLAVE', 
                      'CONT_CLAVEE' => 'CONT_CLAVEE', 
                      'CONT_FECNACI' => 'CONT_FECNACI', 
                      'CONT_FECINSC' => 'CONT_FECINSC', 
                      'CONT_TIPOCODIGO' => 'CONT_TIPOCODIGO'  ); 
    }
     public function validation()
    {
    $this->validate(
    new UniquenessValidator(
    [
    'field'   => 'CONT_CEDULA',
    'message' => 'Sorry, That username is already taken',
    ]
    )
    );

    if ($this->validationHasFailed() == true) {
    return false;
    }
    }
    public function getSource() {
        return 'SPM_CONTACTO';
    }

    public static function find($parameters = null) {
        return parent::find($parameters);
    }

    public static function findFirst($parameters = null) {
        return parent::findFirst($parameters);
    }

}