sql

sql pdo php where in variable

大城市里の小女人 提交于 2021-02-11 18:11:18
问题 I'd like to select some data from my database using variables. Here is a short version of my code: // $a is either null or something like [1, 2] if ($a) { $debug = implode(',', $a); } else { $debug = [0-9]; } $sql = "SELECT id FROM user WHERE id IN ($debug)" How can I achieve that I get only user 1 and 2 (= value in $a ) if $a is set and all user if $a is not set? 回答1: First : be aware when you directly inject string inside queries, because you can be target of a SQL Injection Second : change

sql pdo php where in variable

こ雲淡風輕ζ 提交于 2021-02-11 18:08:11
问题 I'd like to select some data from my database using variables. Here is a short version of my code: // $a is either null or something like [1, 2] if ($a) { $debug = implode(',', $a); } else { $debug = [0-9]; } $sql = "SELECT id FROM user WHERE id IN ($debug)" How can I achieve that I get only user 1 and 2 (= value in $a ) if $a is set and all user if $a is not set? 回答1: First : be aware when you directly inject string inside queries, because you can be target of a SQL Injection Second : change

InnoDB / MySQL - new transaction uses old data on SELECT instead of returning updated data

情到浓时终转凉″ 提交于 2021-02-11 17:57:47
问题 Begin transaction Tx1 Tx1 performs a SELECT Commit Tx1 Begin transaction Tx2 in a different session, using a different connection Tx2 performs a SELECT Update rows in Tx2 Commit Tx2 Begin a new transaction, Tx1 Perform select - get results from step 2(??) Commit Tx1 Begin transaction Tx1 Perform select - get CORRECT results, i.e. the committed updates from Tx2 Very confused... How can this happen? It is happening reliably and consistently. 回答1: Turns out this can happen if the transaction

InnoDB / MySQL - new transaction uses old data on SELECT instead of returning updated data

别来无恙 提交于 2021-02-11 17:57:13
问题 Begin transaction Tx1 Tx1 performs a SELECT Commit Tx1 Begin transaction Tx2 in a different session, using a different connection Tx2 performs a SELECT Update rows in Tx2 Commit Tx2 Begin a new transaction, Tx1 Perform select - get results from step 2(??) Commit Tx1 Begin transaction Tx1 Perform select - get CORRECT results, i.e. the committed updates from Tx2 Very confused... How can this happen? It is happening reliably and consistently. 回答1: Turns out this can happen if the transaction

SQL select where not in select statement

筅森魡賤 提交于 2021-02-11 17:46:09
问题 I'm trying to Select all the records in my database that don't exist in a subquery. For some reason it returns nothing even though the sub query returns 2000 or so rows on it's own and the main query returns over 5000. I need all the records that aren't contained in the subquery SELECT ID FROM PART WHERE NOT ID IN ( SELECT DOCUMENT_ID AS ID FROM USER_DEF_FIELDS WHERE PROGRAM_ID = 'VMPRTMNT' AND ID = 'UDF-0000029' ) 回答1: This is better written as a correlated NOT EXISTS subquery. SELECT ID

SSAS XMLA DISCOVER: how to get list of roles in SSAS database

丶灬走出姿态 提交于 2021-02-11 17:41:46
问题 I am trying to get a list of roles existing in an SSAS DB using XMLA. I need only roles, not other information. I know there is a <RequestType>DISCOVER_XML_METADATA</RequestType> : <Discover xmlns="urn:schemas-microsoft-com:xml-analysis"> <RequestType>DISCOVER_XML_METADATA</RequestType> <Restrictions> <RestrictionList xmlns="urn:schemas-microsoft-com:xml-analysis"> <DatabaseID>SSAS_DB_ID</DatabaseID> </RestrictionList> </Restrictions> <Properties> <PropertyList> </PropertyList> </Properties>

SSAS XMLA DISCOVER: how to get list of roles in SSAS database

≡放荡痞女 提交于 2021-02-11 17:41:21
问题 I am trying to get a list of roles existing in an SSAS DB using XMLA. I need only roles, not other information. I know there is a <RequestType>DISCOVER_XML_METADATA</RequestType> : <Discover xmlns="urn:schemas-microsoft-com:xml-analysis"> <RequestType>DISCOVER_XML_METADATA</RequestType> <Restrictions> <RestrictionList xmlns="urn:schemas-microsoft-com:xml-analysis"> <DatabaseID>SSAS_DB_ID</DatabaseID> </RestrictionList> </Restrictions> <Properties> <PropertyList> </PropertyList> </Properties>

Distributed Transaction on mysql

扶醉桌前 提交于 2021-02-11 17:31:48
问题 I'm working on a distributed system that uses distributed transactions, which means that I may have a transaction that needs to edit multiple databases (on multiple servers) at the same time. In my system there is a controller to manage the distribution. the scenario that I want to satisfy is: server A wants to initiate a distributed transaction. the participants are server A and server B. so server A sends a request to the controller to initiate a distributed transaction. the controller

Distributed Transaction on mysql

喜夏-厌秋 提交于 2021-02-11 17:30:57
问题 I'm working on a distributed system that uses distributed transactions, which means that I may have a transaction that needs to edit multiple databases (on multiple servers) at the same time. In my system there is a controller to manage the distribution. the scenario that I want to satisfy is: server A wants to initiate a distributed transaction. the participants are server A and server B. so server A sends a request to the controller to initiate a distributed transaction. the controller

adodb execute sql command timeout

无人久伴 提交于 2021-02-11 17:27:27
问题 I have this code below and it is hanging on me. It worked fine for several files...but it is now hanging on me and times out with error (-2147217871:Query timeout expired). 'This is what it looks like in SQL Server when I print the string in the immediate window: BEGIN TRAN; INSERT INTO [dbo].[XLSHdr] WITH(TABLOCK) ([HdrID],[TabName],[FileHyperLink],[FileName],[DocumentType],[EmailID],[Subject],[SentDate],[AttachmentName],[TextFileLink],[DateReceived],[Vendor],[ContactName],[ContactNumber],