constraints

Laravel Eloquent truncate - Foreign key constraint

一曲冷凌霜 提交于 2019-12-05 12:25:55
问题 I am having some issues with deleting data using Laravel 5. I seem to be stuck on a 'foreign key constraint', while I don't see why. In my current database model I have a datapoints table, which has a foreign key to the sensors table (datapoints.sensors_id -> sensor.id). The code I am trying: Route::get('/truncateData', function() { DB::table('datapoints')->truncate(); DB::table('sensors')->truncate(); return 'Done...'; }); The result: SQLSTATE[42000]: Syntax error or access violation: 1701

Move all subviews to container view keeping positions and constraints

一曲冷凌霜 提交于 2019-12-05 09:20:23
问题 I'm using Xcode 5 and autolayout in my project. I have a .xib file with a lot of subviews and constraints between them. Now I need to create an intermediate fullscreen container view and put all subviews there. So now I have view->subviews , and I want view->container view->subviews . When I do this in IB by dragging subviews into container view, they all get centred and all constraints get lost. It's going to be a little hard to restore all constraints manually. Is there a smart way to do

Minimization with R nloptr package - multiple equality constraints

不羁的心 提交于 2019-12-05 08:41:30
Is it possible to specify more than one equality constraint in nloptr function in R? The code that I am trying to run is the following: eval_f <- function( x ) { return( list( "objective" = x[3]^2+x[4]^2, "gradient" = c( 0, 0, 2*x[3], 2*x[4] ) ) ) } # constraint functions # equalities eval_g_eq <- function( x ) { constr <- c( x[1] + x[2] + x[3] - 4, x[1]^2 + x[2]^2 + x[4] - 15 ) grad <- c( c(1, 1, 1, 0), c(2*x[1], 2*x[2], 0, 1) ) return( list( "constraints"=constr, "jacobian"=grad ) ) } # initial values x0 <- c( 1, 5, 5, 1 ) local_opts <- list( "algorithm" = "NLOPT_LD_MMA", "xtol_rel" = 1.0e-7

How to find the crashing constraint?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 08:36:54
Sometimes I keep getting errors like these - without any hint to which TextView or Button is meant: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSLayoutConstraint

Unable to drop constraint in SQL server 2005, “Could not drop constraint. See previous errors”

自作多情 提交于 2019-12-05 07:38:07
I'm trying to drop a constraint on a DB table, something like: ALTER TABLE MyTable drop CONSTRAINT FK_MyTable_AnotherTable But the execution just runs and runs. If I stop it I see: Msg 3727, Level 16, State 0, Line 2 Could not drop constraint. See previous errors. Web search throws up various pages but note that the constraint is properly named and I am trying to remove it using the correct name I was having the same issue on SQL Server 2008 R2 , I solved my problem with below line hopefully it will work for someone else as well :) Alter Table [Table Name] DROP Column [Column Name] Found a way

Optimization in R with arbitrary constraints

霸气de小男生 提交于 2019-12-05 07:35:04
问题 I have done it in Excel but need to run a proper simulation in R. I need to minimize function F(x) ( x is a vector) while having constraints that sum(x)=1 , all values in x are [0,1] and another function G(x) > G_0 . I have tried it with optim and constrOptim . None of them give you this option. 回答1: The problem you are referring to is (presumably) a non-linear optimization with non-linear constraints. This is one of the most general optimization problems. The package I have used for these

Named CONSTRAINT benefits

南笙酒味 提交于 2019-12-05 06:10:48
I'm learning SQL and stumbled about CONSTRAINT. I can define them like this: CREATE TABLE products ( product_no integer, name text, price numeric CHECK (price > 0) ); and like this: CREATE TABLE products ( product_no integer, name text, price numeric CONSTRAINT positive_price CHECK (price > 0) ); Why do I give them names? or Why I should or should not give them names? As I can see in this example and most situations in my mind I can't reuse them. So what is the benefit of giving a name to a CONSTRAINT? There are significant benefits of giving explicit names to your constraints. Just a few

When is a value type / reference type constraint useful in C#?

放肆的年华 提交于 2019-12-05 06:08:09
I'm looking for simple examples that demonstrate when the value type / reference type constraints are useful. ... where T : struct // when is this useful? ... where T : class // and what about this? I remember seeing some very nice examples in the past but I just can't find them. It allows you to use as operator on T if it is T:class . It forbids you to compare T with null if T is T:struct . Note that if you omit T:class then you can compare T to null even when T is a value type. [Note: I needed to edit this post a few times before it got correct. At least I hope it is now correct.] The

create table constraint in mysql

邮差的信 提交于 2019-12-05 05:55:09
I have a table in which I have some columns a,b,c and for each column there is another column ,say, (x,y,z) which is dependent on a,b,c respectively. x,y,z will have value 1 if a,b,c has any value and will contain null if a,b,c has null . For an example Lets say, The values stored in a is 2 and x is the column dependent on it. So x will have value as 1 . If the values stored in a is null then x will have value as null . so is there a way in which we can declare this constraint at the time of table creation. Please suggest anything other than triggers. If the purpose of x , y and z is to

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails - Laravel

空扰寡人 提交于 2019-12-05 04:58:10
I know that this question has already been asked, but I still can't find what I'm doing wrong. I'm using the framework Laravel. I have 2 tables (Users and Locations). When I want to create a User, I get the error message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails ( festival_aid . users , CONSTRAINT fk_users_locations1 FOREIGN KEY ( location_id ) REFERENCES locations ( location_id ) ON DELETE CASCADE ON UPDATE NO ACTION) (SQL: insert into users ( user_id , user_email , location_id ) values (?, ?, ?)) (Bindings: array (