uepg / laravel-sybase

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

Using the user together with the table #27

Open broodstare opened 7 years ago

broodstare commented 7 years ago

Hi, thanks for this great package, but I have a little problem here. When I try to use conditional clauses, like: $list->where('disk_qty', 0)->get(), it shows error message

Illuminate\Database\QueryException with message 'PHP error: Undefined variable: tipos in /var/www/html/blog/vendor/uepg/laravel-sybase/Database/SybaseConnection.php on line 140 (SQL: select * from [dbo].[software] where [disk_qty] = 0)'

The type of the column disk_qty is int, how should I fix this problem? Thanks.

mainginski commented 7 years ago

I really appreciate your use and feedback! Apparently the package is not adding the fields to the variable that identifies the types. I'll check and in the next few hours I'll give you a position!

broodstare commented 7 years ago

Deeply thanks! @mainginski :D

mainginski commented 7 years ago

How do you define your table in the model?

broodstare commented 7 years ago

Sorry for replying so late. I have another stuff bother me two weeks ago. And now i finally have time to face this problem again. I define my model SoftwareList.php as following:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class SoftwareList extends Model
{
    protected $connection = "sybase";
    protected $table = "my.software";
}

then, I try php artisan tinker in console, and type the following:

>>> SoftwareList::where('soft_name', 'Mac OSX')->get()

and the console shows that:

Illuminate\Database\QueryException with message 'PHP error:  
Undefined variable: tipos in /var/www/html/software-management/vendor/uepg/laravel-sybase/Database/SybaseConnection.php 
on line 140 (SQL: select * from [my].[software] where [soft_name] = Mac OSX)'

thanks for helping, and sorry i'm so late to reply.

mainginski commented 7 years ago

I am going on vacation for two weeks, however, I imagine your problem is because you are putting your username in $table, laravel-sybase does NOT support this yet, only database..table or table, while your attempt was user.table. If it is not possible to hide the user, you will have to do the encoding, or wait for my return.

mainginski commented 7 years ago

A feedback?

broodstare commented 7 years ago

No, i use query builder instead of ORM, e.g. $user = DB::connection('sybase')->table('table_name')->where('username', $username)->get();

But, i really hope to use ORM, it can save many time and distinguish different business models.

broodstare commented 7 years ago

I just remove username before the table, e.g.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class SoftwareList extends Model
{
    protected $connection = "sybase";
    protected $table = "software"; // <--- change here
}

After that, it works.

mainginski commented 7 years ago

Ok, thank you for giving a comeback. The problem does exist even though it is bypassed.