public function exists(): bool
    {
        $tableKey = $this->getKeyName();

        //If key isn't set we cant associate this record with DB
        if (! isset($this->$tableKey))
        {
            return false;
        }

        $sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key LIMIT 1)';
        $query = DB::getConnection()->prepare($sql);
        $query->execute(['key' => $this->getKey()]);

        return boolval($query->fetchColumn(0));
    }
public function exists(): bool
    {
        $tableKey = $this->getKeyName();

        //If key isn't set we cant associate this record with DB
        if (! isset($this->$tableKey))
        {
            return false;
        }

        $sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key LIMIT 1)';
        $query = DB::getConnection()->prepare($sql);
        $query->execute(['key' => $this->getKey()]);

        return boolval($query->fetchColumn(0));
    }
public function exists ( ) : bool { $ tableKey = $ this -> getKeyName ( ) ; //If key isn't set we cant associate this record with DB if ( ! isset ( $ this -> $ tableKey ) ) { return false ; } $ sql = 'SELECT EXISTS(SELECT ' . $ tableKey . ' FROM ' . $ this -> getTableName ( ) . ' WHERE ' . $ this -> getKeyName ( ) . ' = :key LIMIT 1)' ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; $ query -> execute ( [ 'key' => $ this -> getKey ( ) ] ) ; return boolval ( $ query -> fetchColumn ( 0 ) ) ; }
Check does the current item exist.

@return bool
Check does the current item exist .