Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the user together with the table #27

Open
broodstare opened this issue Dec 7, 2016 · 9 comments
Open

Using the user together with the table #27

broodstare opened this issue Dec 7, 2016 · 9 comments

Comments

@broodstare
Copy link

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
Copy link
Collaborator

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
Copy link
Author

Deeply thanks! @mainginski :D

@mainginski
Copy link
Collaborator

How do you define your table in the model?

@broodstare
Copy link
Author

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
Copy link
Collaborator

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 mainginski reopened this Dec 23, 2016
@mainginski mainginski changed the title 'PHP error: Undefined variable: tipos Using the user together with the table Dec 23, 2016
@mainginski
Copy link
Collaborator

A feedback?

@broodstare
Copy link
Author

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
Copy link
Author

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants