When i try get lat,lng from db. it is rounded but i wanna get exactly.
Value from db: float(48.835792541503906), float(2.280343294143677)
Value when get: float(48.835792541504), float(2.2803432941437)
That is also problem when save to db.
How to solve that ?
Float is not right data type for your data. Try DECIMAL.
I assume you are using MySQL but syntax is similar to other SQL databases.
Related
Hi Guys i wanna ask something
I have column in database mysql like :
199910192022032006
but when laravel datatable show that data column, its change like:
199910192022032000
why its can be happen ?
what data type are you using? integer? try to change into float or double or maybe varchar
I have 33 results on my DB where this boolean field (resolvido) is showing zero, if I run the SQL query it retrieves the results, however in the model the collection always comes empty.
If I change to Model::where('resolvido',1)->get(), I do get the correspondent results, however the Model::where('resolvido',0)->get() or the Model::where('resolvido',false)->get() or even using the query builder and raw sql, the collection never picks up those 33 results where resolvido = 0.
I've also tried in Tinker and it always comes up empty.
Migration:
$table->boolean('resolvido')->nullable();
On DB comes up as TINYINT
Any tips on what it might be?
Thanks in advance
Naturally, there is no boolean data type for MySQL but rather uses TINYINT (0 or 1) for this.
Laravel's query builder, allows using boolean in the where clause. You might want to try these:
Model::where('resolved', true)->get();
Model::where('resolved', false)->get();
Since you've set the resolved column in the DB as nullable, you might also want to try:
Model::where('resolved', null)->get();
If you don't want that behavior use $table->boolean('resolved')->default(false) instead
Try this
Model::where('resolved', null)->get()
or
Model::where('resolved', '')->get()
I am retrieving the data from OracleDB using occi in my application.
While retrieving it, I found that the digits after decimal points were not properly retrieved.
For example, in the DB the original value was 12345.12 but while retrieving from resultset the value i got was 12345.1.
I need to retrieve the whole value (preferably double helps me a lot for my application mapping purpose). Any suggestions will help me a lot.
column in the Oracle DB is NUMBER(11,2) datatype.
I tried to retrieve from result set in the following ways but still got the same truncated value in it.
resultSet -> getDouble(1);
Number nr = resultSet -> getNumber(1);
double d = nr.operator double();
I have tried resultSet->getString(1) and able to get the whole value. Yes i need to cast it to double but getting the data is important than casting. So i will go for it. If anyone has any better solution post it and I am ready to take it.
I am using Laravel 5.1. I want to get milliseconds precision for created_at that I get from the database.
I have tried the solution given for this question. But there isn't any change. Also I tried raw query. Still I get only up to seconds. Is there any way to get millisecond precision?
It may be a problem about your column type. Assuming you are using MySQL, you should manually add (or modify) a column with type TIMESTAMP(3) on your table:
\DB::statement("ALTER TABLE `my_table` ADD COLUMN my_col TIMESTAMP(3) NULL");
More information here: https://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html
I am working with Yii 2.0. Here is my field which has serialize value now i want to find that if 94 exist in this field than i need all values from this row.
post_parents: a:2:{i:0;s:1:"6";i:1;s:2:"94";}
All efforts will be appriciated & thanks in advance
This is a sql problem rather than Yii. Here is sam problem: Unserialize through query at database level itself
Build query like that:
$query->andWhere('your_field_here REGEXP '.*;s:[0-9]+:"your_value_here".*');