Invalid text representation 7 error invalid input syntax for type integer

Never seen such error: ERROR [22P02] ERROR: invalid input syntax for integer: ""; Error while executing the query Creating table: Public Function PrimkCreate(ByVal myPrimkTable As String, ...

Never seen such error:

ERROR [22P02] ERROR: invalid input syntax for integer: «»; Error while executing the query

Creating table:

    Public Function PrimkCreate(ByVal myPrimkTable As String, ByVal nCon As OdbcConnection) As Integer
    Dim ans As Integer
    Dim cCommand As OdbcCommand = New OdbcCommand("CREATE TABLE IF NOT EXISTS " + myPrimkTable + "(" & _
            "prm_id int NOT NULL, " & _
            "pkni text, " & _
            "pdatum text, " & _
            "pdatumnaplate text, " & _
            "pdanaodgode int, " & _
            "puldok text, " & _
            "puldokbroj text, " & _
            "pdatumk text, " & _
            "pvrijemek text, " & _
            "pdobid int, " & _
            "pdoboib text, " & _
            "pnabc double precision, " & _
            "purab double precision, " & _
            "ppdv double precision, " & _
            "ppnak double precision, " & _
            "pprodc double precision, " & _
            "pvrstaprimke int, " & _
            "pzapisniktekst text, " & _
            "prez text, " & _
            "CONSTRAINT " & myPrimkTable & "_pkey PRIMARY KEY(prm_id))", nCon)

    ans = cCommand.ExecuteNonQuery()
    cCommand.Dispose()
    Return ans
End Function

Update code:

    Public Function update_LPrimk(ByRef primk As Integer, ByVal mCon As OdbcConnection) As Integer

    Dim retval As Integer
    Dim uCmd As OdbcCommand = New OdbcCommand("UPDATE " & myPrimkTable & " SET " & _
                "prm_id=" & primk & ", " & _
                "pkni='" & prm.pKni & "', " & _
                "pdatum='" & prm.pDatum & "', " & _
                "pdatumnaplate='" & prm.pDatumNaplate & "', " & _
                "pdanaodgode=" & prm.pDanaodgode & ", " & _
                "puldok='" & prm.pUlDok & "', " & _
                "puldokbroj='" & prm.pUlDokBroj & "', " & _
                "pdatumk='" & prm.pDatumk & "', " & _
                "pvrijemek='" & prm.pVrijemek & "', " & _
                "pdobid='" & prm.pDobID & "', " & _
                "pdoboib='" & prm.pDobOib & "', " & _
                "pnabc='" & Replace(prm.pNabc.ToString, ",", ".") & "', " & _
                "purab='" & Replace(prm.pURab.ToString, ",", ".") & "', " & _
                "ppdv='" & Replace(prm.pPdv.ToString, ",", ".") & "', " & _
                "ppnak='" & Replace(prm.pPnak.ToString, ",", ".") & "', " & _
                "pprodc='" & Replace(prm.pProdc.ToString, ",", ".") & "', " & _
                "pvrstaprimke=" & prm.pVrstaPrimke & ", " & _
                "pzapisniktekst='" & prm.pZapisnikTekst & "', " & _
                "prez='" & prm.pRez & "' " & _
                "WHERE prm_id=" + primk.ToString, mCon)

    retval = uCmd.ExecuteNonQuery()
    uCmd.Dispose()
    Return retval
End Function

Query looks exactly like this:

UPDATE primke SET prm_id=1, pkni='U', pdatum='07.01.2013', pdatumnaplate='10.01.2013',
pdanaodgode=3, puldok='ghkzug gugug', puldokbroj='jkhk', pdatumk='', pvrijemek='', 
pdobid='', pdoboib='', pnabc='0', purab='0', ppdv='0', ppnak='0', pprodc='0', 
pvrstaprimke=0, pzapisniktekst='', prez='' WHERE prm_id=1

I have many tables where I run similar commands but have never seen such an error.
What might be the problem?

  • Laravel Version: 5.6.39
  • PHP Version: 7.3.11
  • Database Driver & Version:PostgreSQL 12

Description:

I have the following error while entering data in Store HELP ME PLZ:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type integer: «» (SQL: insert into «pmieducar».»servidor_alocacao» («ref_usuario_cad», «ref_usuario_exc», «data_cadastro», «ano», «ref_cod_escola», «periodo», «data_admissao», «ref_cod_servidor_funcao», «ref_cod_funcionario_vinculo», «hora_inicial», «hora_final», «carga_horaria», «hora_atividade», «horas_excedentes») values (1, 1, 2019-11-27 10:34:05, 2019, 39, 1, 2018-10-26, , , 16:54:06, , 12:38:00, , ) returning «cod_servidor_alocacao»)

Controller
`<?php

namespace AppHttpControllersServidor;

use IlluminateHttpRequest;
use AppInstituicao;
use AppHttpControllersController;
use AppModelsServidorServidor;
use AppModelsServidorServidorAlocacao;
use AppModelsPmieducarEscola;
use AppModelsPortalFuncionarioVinculo;
use AppModelsServidorServidorFuncao;
use AppModelsServidorTipoFuncao;

class ServidorAlocacaoController extends Controller
{
private $rota = ‘Admin/servidor/servidor/alocao’;
// public $rotaAlocacao = ‘Admin/servidor/servidor/alocao’;
private $view = ‘admin.servidor.servidor.alocacao’;
private $titulo = ‘Alocação de Servidor’;

public function __construct(){
    view()->share('rota', 'alocacao.');
    // view()->shere('rota' , 'alocacao.');
    view()->share('titulo', $this->titulo);
    view()->share('instituicao', Instituicao::orderBy('nm_instituicao', 'asc')->get());
    view()->share('vinculo', FuncionarioVinculo::orderBy('cod_funcionario_vinculo' , 'asc')->get());
    view()->share('funcao', TipoFuncao::orderBy('cod_funcao' , 'asc')->get());

}


/**
 * Display a listing of the resource.
 *
 * @return IlluminateHttpResponse
 */
public function index($cod_servidor)
{
    
    $servidor = Servidor::find($cod_servidor);
    
    return view('Admin.servidor.servidor.alocacao.index' , compact('servidor'));

}

/**
 * Show the form for creating a new resource.
 *
 * @return IlluminateHttpResponse
 */
public function create($cod_servidor )
{
    
    


    $servidor = Servidor::find($cod_servidor);
    // return $servidor;        
    $escola = Escola::where('ref_cod_instituicao', $servidor->ref_cod_instituicao)->OrderBy('ref_cod_instituicao')->get();
    
    return view('Admin.servidor.servidor.alocacao.create' , compact('servidor' , 'escola'));


    //
}

/**
 * Store a newly created resource in storage.
 *
 * @param  IlluminateHttpRequest  $request
 * @return IlluminateHttpResponse
 */
public function store(Request $request , ServidorAlocacao $data)
{
    
    $data->carga_horaria               = $request->carga_horaria;
    $data->periodo                     = $request->periodo;
    $data->ref_cod_servidor_funcao     = $request->ref_cod_servidor_funcao;
    $data->ref_cod_funcionario_vinculo = $request->ref_cod_funcionario_vinculo;
    $data->ano                         = $request->ano;
    $data->data_admissao               = $request->data_admissao;
    $data->hora_inicial                = $request->hora_inicial;
    $data->hora_final                  = $request->hora_final;
    $data->hora_atividade              = $request->hora_atividade;
    $data->horas_excedentes            = $request->horas_excedentes;
// dd($data)        ;
    $data->save();

    if($data->fill($request->all())->save() != null){
        return redirect('Admin/servidor/servidor/alocacao/cod_servidor}')->with(['success' => 'Servidor alocado com sucesso.']);
    }else{
        return redirect('Admin/servidor/servidor/alocacao/{cod_servidor}')->with(['error' => 'Ocorreu um erro. Tente novamente mais tarde.']);
    }

}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return IlluminateHttpResponse
 */
public function show($id)
{
    //
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return IlluminateHttpResponse
 */
public function edit($id)
{
    //
}

/**
 * Update the specified resource in storage.
 *
 * @param  IlluminateHttpRequest  $request
 * @param  int  $id
 * @return IlluminateHttpResponse
 */
public function update(Request $request, $id)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return IlluminateHttpResponse
 */
public function destroy($id)
{
    //
}

}
Model<?php

namespace AppModelsServidor;

use AppModelsPmieducarEscola;
use AppModelsPortalFuncionarioVinculo;
use IlluminateDatabaseEloquentModel;

class ServidorAlocacao extends Model
{
protected $table = ‘pmieducar.servidor_alocacao’;
protected $primaryKey = ‘cod_servidor_alocacao’;
protected $fillable = [‘cod_servidor_alocacao’, ‘ref_ref_cod_instituicao’, ‘ref_usuario_exc’,
‘ref_usuario_cad’, ‘ref_cod_escola’, ‘ref_cod_servidor’, ‘data_cadastro’, ‘data_exclusao’,
‘ativo’, ‘carga_horaria’, ‘periodo’, ‘ref_cod_servidor_funcao’, ‘ref_cod_funcionario_vinculo’,
‘ano’, ‘data_admissao’, ‘hora_inicial’, ‘hora_final’, ‘hora_atividade’, ‘horas_excedentes’,
];
public $timestamps = false;

public function servidor(){
    return $this->belongsTo(Servidor::class, 'ref_cod_servidor', 'cod_servidor');
}

public function escola(){
    return $this->belongsTo(Escola::class, 'ref_cod_escola', 'cod_escola');
}

public function funcao(){
    return $this->belongsTo(ServidorFuncao::class, 'ref_cod_servidor_funcao', 'cod_servidor_funcao');
}
public function vinculo(){
    return $this->belongsTo(FuncionarioVinculo::class, 'ref_cod_funcionario_vinculo', 'cod_funcionario_vinculo');
}

}
View@extends(‘dashboard.app’)

@section(‘htmlheader_title’)
— {{$titulo}}
@endsection

@section(‘contentheader_title’)
{{$titulo}}
@endsection

@section(‘contentheader_icon’)
fa-graduation-cap
@endsection

@section(‘main-content’)

{{— Listagem dos Cursos —}}

{{$titulo}}

{{ csrf_field() }}

Instituição:

                                </div><!-- /.form-group -->
                            </div><!-- /.col -->
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>Servidor:</label>
                                    <input class="form-control" type="text" disabled="disabled" name="" id="" 
                                    placeholder="{{$servidor->pessoa->nome}}">
                                </div><!-- /.form-group -->
                            </div><!-- /.col -->
                        </div><!-- /.row-->
                        <!-- row-->
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label>Carga Horária do Servidor:</label>
                                    <input class="form-control" type="text" disabled="disabled" name="" id="" 
                                    placeholder="{{$servidor->carga_horaria}} horas">                                    </div><!-- /.form-group -->
                                </div><!-- /.col -->
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label>Ano *:</label>
                                        <input class="form-control" type="text" name="ano" id="" required
                                        placeholder="Ano">                                    
                                    </div><!-- /.form-group -->
                                </div><!-- /.col -->
                                    <div class="col-md-6">
                                            <div class="form-group">
                                                <label>Escola *:</label>
                                                <select class="form-control" name="ref_cod_escola" id="" required>
                                                    <option value="ref_cod_escola">Selecione
                                                            
                                                    </option>
                                                    @if (isset($escola))
                                                        @foreach ($escola as $it)
                                                            <option value="{{$it->cod_escola}}"> {{$it->pessoa->nome}} </option>
                                                        @endforeach
                                                    @endif
                                                </select>                                   </div><!-- /.form-group -->
                                            </div><!-- /.col -->
                                    </div><!-- /.-->
                                    <div class="row">
                                            <div class="col-md-6">
                                                    <div class="form-group">
                                                        <label>Periodo *:</label>
                                                        <select required class="form-control" name="periodo" id="" required>
                                                            <option value="">Selecione</option>
                                                            <option value="1">Matutino</option>
                                                            <option value="2">Vespertino</option>
                                                            <option value="3">Noturno</option>
        
        
        
                                                        </select>
                                                    </div><!-- /.form-group -->
                                            </div><!-- /.col -->
                                            
                                            <div class="col-md-3">
                                                    <div class="form-group">
                                                        <label>Data de admissão :</label>
                                                        <input class="form-control" type="date" name="data_admissao" id="" 
                                                        placeholder="dd/mm/yyyy">                                    
                                                    </div><!-- /.form-group -->
                                            </div><!-- /.col -->
                                            
                                    </div><!-- /.row-->
                                    <div class="row">
                                            <div class="col-md-6">
                                                    <div class="form-group">
                                                        <label>Função *:</label>
                                                        <select required class="form-control" name="ref_cod_servidor_funcao" id="" >
                                                                <option value="">Selecione</option>
                                                            @if (isset($funcao))
                                                                @foreach ($funcao as $it)
                                                                    @if($it->cod_funcao !== null)
                                                                    <option value="{{$it->ref_cod_servidor_funcao}}"> {{$it->nm_funcao}} </option>
                                                                    @endif
                                                                @endforeach
                                                            @endif
            
            
            
                                                            </select>                        
                                                    </div><!-- /.form-group -->
                                            </div><!-- /.col -->  
                                            <div class="col-md-6">
                                                    <div class="form-group">
                                                        <label>Vunculo *:</label>
                                                        <select required class="form-control" name="ref_cod_funcionario_vinculo" id="" >
                                                                <option value="">Selecione</option>
                                                                
                                                            @if (isset($vinculo))
                                                                @foreach ($vinculo as $it)
                                                                    @if($it->cod_funcionario_vinculo !== null)
                                                                    <option value="{{$it->ref_cod_funcionario_vinculo}}"> {{$it->nm_vinculo}} </option>
                                                                    @endif
                                                                @endforeach
                                                            @endif
            
            
                                                            </select>                        
                                                    </div><!-- /.form-group -->
                                            </div><!-- /.col -->  
                                    </div>
                                </div><!-- /.-->
                                <div class="card-header">
                                        <h3 class="mb-0">Informações Sobre Carga Horaria</h3>
                                </div>
                                <div class="row">
                                    
                                    
                                    <div class="col-md-2">
                                            <div class="form-group">
                                                <label>Horario de Início:</label>
                                                <input class="form-control" type="time" step="2" name="hora_inicial" id="" 
                                                >                                    
                                            </div><!-- /.form-group -->
                                    </div><!-- /.col -->
                                    <div class="col-md-2">
                                            <div class="form-group">
                                                <label>Horario de termíno:</label>
                                                <input class="form-control" type="time" step="2" name="hora_final" id="" 
                                                >                                    
                                            </div><!-- /.form-group -->
                                    </div><!-- /.col -->  
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label>Carga horária *:</label>
                                            <input class="form-control" type="time" step="2" name="carga_horaria" id="carga_horaria" 
                                            required>                                    
                                        </div><!-- /.form-group -->
                                </div><!-- /.col --> 
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <label>Hora atividade:</label>
                                        <input class="form-control" type="time" step="2" name="hora_atividade" id="" 
                                        >                                    
                                    </div><!-- /.form-group -->
                            </div><!-- /.col --> 
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label>Horas excedentes:</label>
                                    <input class="form-control" type="time" step="2" name="horas_excedentes" id="" 
                                    >                                    
                                </div><!-- /.form-group -->
                            </div><!-- /.col --> 
                            </div><!-- /.row-->
                            <div class="row">
                            </div>
                        
                        

                        <div style="width:100%;text-align:center">
                            <div class="form-group ">
                                <button class="btn btn-primary" type="submit">Salvar</button>
                                <a class="btn btn-danger" href="{{route($rota.'index' , $servidor->cod_servidor)}}"> Voltar </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>

@endsection

@section(‘scripts-footer’)
<script src=»https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.js»></script>
<script src=»{{ asset(‘/admins/js/servidor/servidor.js’) }}»></script>
@endsection
`

Steps To Reproduce:

#laravel #api

Вопрос:

У меня есть проект в Laravel 7, и он сработал. Но по некоторым причинам я хочу провести рефакторинг на Laravel 8. Другие в порядке, но у этого маршрута есть проблема.

Вот мой код маршрута в L7 (сработал) и L8 (ошибка): Маршрут api.php:

 L7:
Route::get('/coa/find', [SettingCoaController::Class, 'findCoa']);

L8:
Route::get('coa/find', 'SettingCoaController@findCoa');
 

И это мой контроллер (тот же код):

 namespace AppHttpControllersSetting;

use AppHttpControllersController;
use IlluminateHttpRequest;
use DB;
use IlluminateSupportFacadesValidator;
use AppCoa;

class CoaController extends Controller
{
    public function findCoa(Request $request)
    {
        $isi = $request -> isi; 
        $findCoa = Coa::where('coaid', 'ilike', "%" . $isi . "%")
        ->orWhere('deskripsi', 'ilike', "%" . $isi . "%")
        ->paginate(20);
        // $findCoa = DB::table('coa')
        // ->where('coaid', 'ilike', "%" . $isi . "%")
        // ->orWhere('deskripsi', 'ilike', "%" . $isi . "%")
        // ->paginate(20);

        return response()->json($findCoa);
    }
 }
 

Либо я использую БД, либо модель в приложенииCoa, это всегда приводит к этой ошибке:

 IlluminateDatabaseQueryException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type integer: amp;quot;findamp;quot; (SQL: select * from amp;quot;coaamp;quot; where amp;quot;idamp;quot; = find limit 1) in file /Users/yosep/Dropbox/projects/Laravel8/kie-l8/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 692
 

Я не понял, почему запрос стал:
select * from amp;quot;coaamp;quot; where amp;quot;idamp;quot; = find limit 1 ? Независимо от того, меняю ли я контроллер, это всегда приводит к этой ошибке. Но другие методы (индекс, показать($id), уничтожить) в порядке. Только этот все еще испорчен.

Комментарии:

1. Уже пробовал, но все равно не повезло, сообщение об ошибке все то же самое. Запрос по ошибке не совпадает с контроллером.

Ответ №1:

Я не знаю, как это работает, но я меняю api.php, из этого:

 Route::get('/coa/{id}', [SettingCoaController::Class, 'show']);
Route::get('coa/cari', [SettingCoaController::Class, 'findCoa']);

 

к этому:

 Route::get('coa/cari', [SettingCoaController::Class, 'findCoa']);
Route::get('/coa/{id}', [SettingCoaController::Class, 'show']);
 

И то и другое работает!

Может ли кто-нибудь объяснить, почему show api/метод не смог написать первым и привел к этой ошибке?

Комментарии:

1. При первой настройке маршрута, когда вы звоните /coa/cari , ваш маршрут '/coa/{id}' выбирается первым (в основном говорится «URL , начинающийся с /coa/ , а затем что угодно). Вы также можете ограничить параметр {id} использованием только целых чисел с использованием ограничений регулярных выражений , что должно заставить ваши маршруты работать так же, как в вашей первой настройке

Ответ №2:

Первое, что было изменено в привязке контроллера маршрута Laravel 8, чтобы ваш маршрут работал

Маршрут::get(«coa/найти», «НастройкаCoaController@findCoa»);

Вам следует обновить свой «RouteServiceProvider.php» найдите «защищенное пространство имен $ = » ПриложениеHttpКонтроллеры»; » или просто добавьте эту строку, это сработает!

#240 1003788-240.patch 4.72 KB stefan.r

PASSED: [[SimpleTest]]: [MySQL] 41,464 pass(es). View

#238 1003788-238.patch 5.02 KB stefan.r

PASSED: [[SimpleTest]]: [MySQL] 41,463 pass(es). View

#237 1003788-237.patch 5.02 KB stefan.r

PASSED: [[SimpleTest]]: [MySQL] 41,456 pass(es). View

#232 1003788-232.patch 4.62 KB stefan.r

FAILED: [[SimpleTest]]: [MySQL] Drupal installation failed. View

#204 1003788-8.x-entity-id-D7-204.patch 2.53 KB stefan.r

PASSED: [[SimpleTest]]: [MySQL] 41,137 pass(es). View

#189 1003788-8.x-entity-id-189.patch 4.37 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 79,483 pass(es). View

#189 interdiff.txt 1.82 KB stefan.r #185 interdiff.txt 1.01 KB stefan.r #185 1003788-8.x-entity-id-185.patch 5.38 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 79,029 pass(es). View

#183 interdiff.txt 2.55 KB stefan.r #181 1003788-8.x-entity-id-181.patch 4.25 KB stefan.r

FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 78,913 pass(es), 14 fail(s), and 0 exception(s). View

#176 1003788-8.x-entity-id-withextracheck-176.patch 2.41 KB gaas

FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 78,855 pass(es), 14 fail(s), and 0 exception(s). View

#172 1003788-172-drupal7.patch 808 bytes gngn

FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch 1003788-172-drupal7_0.patch. Unable to apply patch. See the log in the details link for more information. View

#160 1003788-8.x-entity-id-withoutextracheck-160.patch 2.33 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,959 pass(es). View

#160 1003788-8.x-entity-id-withextracheck-160.patch 2.37 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,903 pass(es). View

#159 interdiff.txt 684 bytes stefan.r #159 1003788-8.x-entity-id-159.patch 2.35 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,736 pass(es). View

#155 1003788-8.x-entity-id-152.patch 2.41 KB JimmyAx

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,774 pass(es). View

#153 interdiff.txt 472 bytes stefan.r #153 1003788-8.x-entity-id-151.patch 2.24 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,734 pass(es). View

#150 interdiff.txt 1.85 KB stefan.r #150 1003788-8.x-entity-id-150.patch 2.26 KB stefan.r

FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Drupal installation failed. View

#145 1003788-7.x-entity-id-145.patch 2.46 KB stefan.r

PASSED: [[SimpleTest]]: [MySQL] 41,155 pass(es). View

#142 1003788-8.x-entity-id-142.patch 2.59 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,572 pass(es). View

#141 1003788-8.x-entity-id-140.patch 2.59 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,551 pass(es). View

#139 1003788-8.x-entity-id-139.patch 2.61 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,555 pass(es). View

#138 1003788-8.x-entity-id-138.patch 2.7 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,553 pass(es). View

#137 interdiff.txt 3.13 KB stefan.r #136 1003788-8.x-entity-id-136.patch 2.7 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,551 pass(es). View

#136 1003788-8.x-entity-id-136.patch 2.7 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,547 pass(es). View

#131 1003788-8.x-entity-id-131.patch 2.3 KB stefan.r

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,510 pass(es). View

#124 1003788-8.x-entity-id-2-tests.patch 800 bytes JimmyAx

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,817 pass(es). View

#124 1003788-8.x-entity-id-2.patch 2.67 KB JimmyAx

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,883 pass(es). View

#122 1003788-8.x-entity-id.patch 1.85 KB JimmyAx

FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Drupal installation failed. View

#114 1003788-8.x-entity-id-datatype-support_1.patch 1.5 KB bzrudi71

PASSED: [[SimpleTest]]: [MySQL] 63,686 pass(es). View

#108 1003788-8.x-entity-id-datatype-support.patch 1.52 KB Josh Waihi

FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1003788-8.x-entity-id-datatype-support_0.patch. Unable to apply patch. See the log in the details link for more information. View

#106 1003788-8.x-entity-id-datatype-support.patch 1.47 KB Josh Waihi

FAILED: [[SimpleTest]]: [MySQL] Drupal installation failed. View

#76 1003788-76-D7-entity_load-sanity-check-any-integer_do-not-test.patch 1.73 KB wiifm #71 1003788-71-entity_load-sanity-check-any-integer.patch 1.83 KB Alan D.

PASSED: [[SimpleTest]]: [MySQL] 34,240 pass(es). View

#70 1003788-70-drupal7.patch 867 bytes robhardwick

FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1003788-70-drupal7.patch. Unable to apply patch. See the log in the details link for more information. View

#57 1003788-57-drupal7.patch 852 bytes john_brown

FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1003788-57-drupal7.patch. Unable to apply patch. See the log in the details link for more information. View

#56 1003788 drupal 7.9 with other changes.patch 2.29 KB john_brown

FAILED: [[SimpleTest]]: [MySQL] Fetch test patch: failed to retrieve [1003788 drupal 7.9 with other changes.patch] from [drupal.org]. View

#54 1003788 workaround.txt 4.12 KB john_brown #51 1003788-51-entity_load-sanity-check.patch 2.45 KB twistor

PASSED: [[SimpleTest]]: [MySQL] 33,148 pass(es). View

#49 1003788-49-entity_load-sanity-check.patch 1.69 KB twistor

FAILED: [[SimpleTest]]: [MySQL] 33,151 pass(es), 1 fail(s), and 0 exception(es). View

#47 1003788-47.patch 1.63 KB pwolanin

FAILED: [[SimpleTest]]: [MySQL] 32,909 pass(es), 28 fail(s), and 31 exception(es). View

#23 1003788-faster-implementation-of-sanity-checking-2.patch 1.05 KB Alan D.

FAILED: [[SimpleTest]]: [MySQL] 29,462 pass(es), 1 fail(s), and 0 exception(es). View

#13 1003788-faster-implementation-of-sanity-checking.patch 1.06 KB Josh Waihi

FAILED: [[SimpleTest]]: [MySQL] 29,400 pass(es), 1 fail(s), and 0 exception(es). View

#11 entity-load-text-filter-1003788-11.patch 2.14 KB Alan D.

PASSED: [[SimpleTest]]: [MySQL] 29,879 pass(es). View

#9 non-int-entity-ids.diff 782 bytes Alan D.

FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch non-int-entity-ids.diff. View

#6 1003788.2.patch 1014 bytes bellHead

FAILED: [[SimpleTest]]: [MySQL] 31,315 pass(es), 2 fail(s), and 5,699 exception(es). View

#4 1003788.patch 1.07 KB bellHead

FAILED: [[SimpleTest]]: [MySQL] 31,236 pass(es), 2 fail(s), and 5,723 exception(es). View

386 votes

1 answers

Get the solution ↓↓↓

Morning guys,
I have two database that are linked, the tables areUser andTheme, have in mind im not that familliar with php and symfony framework.
a Theme is linked to a User :

/src/Entity/Theme.php
/**
     * @ORMManyToOne(targetEntity="AppEntityUser", inversedBy="published")
     * @ORMJoinColumn(nullable=false)
     */
   private $user; 

I’m trying to setup a function that would display all the Theme written by this User based of his lastname, from what i understood@ORMManyToOne(targetEntity="AppEntityUser", inversedBy="published") makes sure my theme isnt only linked by theuser_id but the user entity.

In myThemeController.php my function is set up this way :

/**
     * @Route("/theme/show/{lastname}", name="theme_created_by")
     * [email protected] User $ThemeByUser
     */
    public function userThemes(User $ThemeByUser){
        $html =  $this->twig->render('theme/index.html.twig', [
            'themes' => $this->themeRepository->findBy(
                ['User' => $ThemeByUser], ['created_at' => 'DESC']),
        ]);
        return new Response($html);
    }

It seems like the query made by Doctrine isn’t going thru i get this error :

An exception occurred while executing 'SELECT t0.id AS id_1, t0.name AS name_2, t0.created_at AS created_at_3, t0.updated_at AS updated_at_4, t0.user_id AS user_id_5 FROM theme t0 WHERE t0.id = ?' with params ["Roland"]:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type integer: "Roland"

Which mean Doctrine is expecting a int as a parameter but it is receiving a string. While reading the documentation it seems like the parameters are converted to match anything in the data. Maybe im dont fully understand how it works, just need a little guidance.
thank you

2021-11-17

Write your answer


270

votes

Answer

Solution:

Dont know how and why but in my twig file that rendering the function :

<p class="media-body pb-3 mb-0  small lh-125 border-bottom border-gray">
        <strong class="text-gray-dark">Autheur : </strong>
        <a href="{{ path('theme_created_by', {'lastname': theme.user.lastname}) }}">
             {{ theme.user.lastname }}
        </a>
        <br/>
        <a href="{{ path( 'theme_show', {'id' : theme.id} ) }}">
            <strong>{{ theme.name }}</strong><br/>
        </a>

i replace that path line with :

<a href="{{ path('theme_created_by', {'username': theme.user.username}) }}">
             {{ theme.user.lastname }}
        </a>

changed the paramaters passed in my route too : withusername@Route("/themes/by/{username}", name="theme_created_by")
now it works..


Share solution ↓

Additional Information:

Date the issue was resolved:

2021-11-17

Link To Source

Link To Answer
People are also looking for solutions of the problem: unable to determine current zabbix database version: the table «dbversion» was not found.

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

Я пытаюсь создать нотификацию базы данных в Laravel 5.7 и получить это исключение SQL QueryException. Моя переменная $ notifyable в методе toArray — это пользователь и этот id в исключении: invalid input syntax for integer: "10337e35-8da9-4600-b7de-792398eb6f48" является правильным идентификатором для уведомления пользователя. У меня есть таблица уведомлений, настроенная стандартным способом:

Schema::create('notifications', function (Blueprint $table) {
        $table->uuid('id')->primary();
        $table->string('type');
        $table->morphs('notifiable');
        $table->text('data');
        $table->timestamp('read_at')->nullable();
        $table->timestamps();
    });

Моя пользовательская таблица настроена следующим образом:

Schema::create('users', function (Blueprint $table) {
        $table->uuid('id');
        $table->primary('id');
        $table->string('name');
        $table->string('username')->unique();
        $table->string('email');
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
        $table->softDeletes();
    });

Он настроен с uuid как основной идентификатор. Кроме того, само уведомление имеет database в методе via:

public function via($notifiable)
{
    return ['database', 'mail'];
}

Я установил пару свойств в методе toArray. Ничего сложного. Я также попытался вручную вставить в таблицу уведомлений, и я могу вставить запись с notifiable_id как int, но не строку /uuid. Мне кажется, что никакая надежная система не будет настроена, чтобы uuid как идентификаторы. Может быть, это всего лишь небольшая настройка, но я не вижу ее там и думаю, что кто-то другой столкнулся с этим. Ура!

Полное исключение:

Object { message: "SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: "0e7cc3d8-bfca-41c1-99f8-6da9e8887465" (SQL: insert into "notifications" ("id", "type", "data", "read_at", "notifiable_id", "notifiable_type", "updated_at", "created_at") values (f6206d4e-c98f-4ced-a1ee-6a755f073807, App\Notifications\BugTransition, {"bug_id":"be14d750-ba6c-4e70-82f7-a36786ff37f4","workflow_state":"accepted"}, , 0e7cc3d8-bfca-41c1-99f8-6da9e8887465, App\User, 2018-10-22 22:35:54, 2018-10-22 22:35:54))", exception: "Illuminate\Database\QueryException", file: "/srv/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php", line: 664,

Понравилась статья? Поделить с друзьями:
  • Invalid syntax python ошибка else
  • Invalid syntax python ошибка elif
  • Invalid syntax python perhaps you forgot a comma ошибка
  • Invalid stored block lengths ошибка
  • Invalid start mode archive offset tlauncher ошибка