我正在尝试根据某个条件更新值,但它不会更新。
这是我的代码
CREATE TABLESPACE TABLESPACE1992
EXTENT MANAGEMENT LOCAL
UNIFORM SIZE 64K
SEGMENT SPACE MANAGEMENT MANUAL
DATAFILE '/home/oracle/app/oracle/oradata/db/tablespace1992.dbf'
SIZE 2M AUTOEXTEND OFF;
CREATE TABLE ORDERS1992 (
TSO_ORDERKEY NUMBER(12) NOT NULL,
TSO_CUSTKEY NUMBER(12) NOT NULL,
TSO_ORDERSTATUS CHAR(1) NOT NULL,
TSO_TOTALPRICE NUMBER(12,2) NOT NULL,
TSO_ORDERDATE DATE NOT NULL,
TSO_ORDERPRIORITY CHAR(15) NOT NULL,
TSO_CLERK CHAR(15) NOT NULL,
TSO_SHIPPRIORITY NUMBER(12) NOT NULL,
TSO_COMMENT VARCHAR(79) NOT NULL,
CONSTRAINT ORDERS1992_PKEY PRIMARY KEY (TSO_ORDERKEY),
CONSTRAINT ORDERS1992_FKEY1 FOREIGN kEY (TSO_CUSTKEY)
REFERENCES CUSTOMER(C_CUSTKEY),
CONSTRAINT ORDERS1992_CHECK1 CHECK( TSO_TOTALPRICE >= 0) ) TABLESPACE TABLESPACE1992;
CREATE TABLE LINEITEM1992 (
TSL_ORDERKEY NUMBER(12) NOT NULL,
TSL_PARTKEY NUMBER(12) NOT NULL,
TSL_SUPPKEY NUMBER(12) NOT NULL,
TSL_LINENUMBER NUMBER(12) NOT NULL,
TSL_QUANTITY NUMBER(12,2) NOT NULL,
TSL_EXTENDEDPRICE NUMBER(12,2) NOT NULL,
TSL_DISCOUNT NUMBER(12,2) NOT NULL,
TSL_TAX NUMBER(12,2) NOT NULL,
TSL_RETURNFLAG CHAR(1) NOT NULL,
TSL_LINESTATUS CHAR(1) NOT NULL,
TSL_SHIPDATE DATE NOT NULL,
TSL_COMMITDATE DATE NOT NULL,
TSL_RECEIPTDATE DATE NOT NULL,
TSL_SHIPINSTRUCT CHAR(25) NOT NULL,
TSL_SHIPMODE CHAR(10) NOT NULL,
TSL_COMMENT VARCHAR(44) NOT NULL,
CONSTRAINT TSLINEITEM_PKEY PRIMARY KEY (TSL_ORDERKEY, TSL_LINENUMBER),
CONSTRAINT TSLINEITEM_FKEY1 FOREIGN kEY (TSL_ORDERKEY)
REFERENCES ORDERS1992(TSO_ORDERKEY),
CONSTRAINT TSLINEITEM_FKEY2 FOREIGN KEY (TSL_PARTKEY)
REFERENCES PART(P_PARTKEY),
CONSTRAINT TSLINEITEM_FKEY3 FOREIGN KEY (TSL_PARTKEY,TSL_SUPPKEY)
REFERENCES PARTSUPP(PS_PARTKEY, PS_SUPPKEY),
CONSTRAINT TSLINEITEM_FKEY4 FOREIGN kEY (TSL_SUPPKEY)
REFERENCES SUPPLIER(S_SUPPKEY),
CONSTRAINT TSLINEITEM_CHECK1 CHECK (TSL_QUANTITY >= 0),
CONSTRAINT TSLINEITEM_CHECK2 CHECK (TSL_EXTENDEDPRICE >= 0),
CONSTRAINT TSLINEITEM_CHECK3 CHECK (TSL_TAX >= 0),
CONSTRAINT TSLINEITEM_CHECK4 CHECK (TSL_DISCOUNT BETWEEN 0.00 AND 1.00) ) TABLESPACE TABLESPACE1992;
我的样本数据就是这样
foreach($div as $key=>$d){
if(!$d['playingDate']){
// SOME CODE GOES HERE.
}else{
// THIS CODE DEOSN'T UPDATE THE WEEKDAY
$div[$key]['date']['weekday'] = $d['weekday'];
}
}
如您所见,第二项包含.......
{
id: 3209,
playingDate: "2019-01-27",
playingTime: "19:00",
weekday: "Mån",
date: {
id: 94,
gameLength: "90",
startingDate: "2018-12-24",
startingTime: "19:00",
weekday: "Mån"
},
{
id: 3209,
playingDate: "2019-01-27",
playingTime: "19:00",
weekday: "Sun",
date: {
id: 94,
gameLength: "90",
startingDate: "2018-12-24",
startingTime: "19:00",
weekday: "Mån"
},
,因此它也应该将工作日的数据也更新为weekday Sun
,但没有。
答案 0 :(得分:0)
您可以简单地使用
$ div [$ key] ['date'] ['weekday'] = date('l',strtotime($ d ['playingTime'])))
这将自动返回您使用的$div
内的工作日。让我知道是否有帮助。
对于这些类型的错误,请尝试转储数组,以便查看是否所有信息都在数组内。
答案 1 :(得分:-1)
您在foreach
语句之前关闭else
。它必须返回一个错误。
在脚本顶部添加此代码,以帮助您调试php:
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);