uepg / laravel-sybase

Connection and Laravel Eloquent driver for Sybase
GNU General Public License v2.0
33 stars 16 forks source link

I do not understand how Sybase queries from the model of laravel #68

Open Montolsky opened 4 years ago

Montolsky commented 4 years ago

$chq_cust = chq_cust::select('active')->where('active', 'y')->get();

error SQLSTATE[HY000]: General error: 20018 SQL Anywhere Error -852: Table name 'syscolumns' is ambiguous [20018] (severity 16) [ SELECT a.name, st.name AS type FROM syscolumns a, systypes b, systypes s, systypes st WHERE a.usertype = b.usertype AND s.usertype = a.usertype AND s.type = st.type AND st.name NOT IN ( 'timestamp', 'sysname', 'longsysname', 'nchar', 'nvarchar' ) AND st.usertype < 100 AND object_name (a.id) = 'dba.chq_cust'] (SQL: select [active] from [dba].[chq_cust] where [active] = y)

nunomazer commented 4 years ago

@Montolsky Try use yourdatabase..tablename in $table var on Model. See #63

omar-uc commented 3 years ago

hey @Montolsky , had the same error, could connect and could query the tables with models, but anytime I tried a WHERE clause I had the error you mentioned.

only using whereRaw I could made it work, not using Where

/* Option A **/ $carrera = \App\Carrera::whereRaw('carrera = 171')->first();

/* Option B - just plain SQL **/ $carrera= DB::select("SELECT * from carreras where carrera = 171");

/** Option C / $carrera= DB::table('carreras')->select('*')->whereRaw('carrera = 171')->get();

elsoftpy commented 5 months ago

Same error but when trying to insert a row into any table.

After trying this solution "tablename in $table var on Model." I got an error saying: Undefined variable $types at /var/www/html/vendor/jcrodriguezt/laravel-sybase/src/Database/Connection.php:447

omar-uc commented 5 months ago

Same error but when trying to insert a row into any table.

After trying this solution "tablename in $table var on Model." I got an error saying: Undefined variable $types at /var/www/html/vendor/jcrodriguezt/laravel-sybase/src/Database/Connection.php:447

Show your model code perhaps