Where's the bug? - cakephp

http://www.neighborrow.com is currently displaying this error:
Warning (512): SQL Error: 1054: Unknown column 'User.rating' in 'order clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 527]
Where's the error in this query?
SELECT `User`.`id`, `User`.`first_name`, `User`.`last_name`, `User`.`email`,
`User`.`password`, `User`.`phone`, `User`.`address`, `User`.`city`, `User`.`zip`,
`User`.`region`, `User`.`verified`, `User`.`residence_id`, `User`.`rating_id`,
`User`.`facebook_id`, `Residence`.`id`, `Residence`.`residence` FROM `users` AS `User`
LEFT JOIN `residences` AS `Residence` ON (`User`.`residence_id` = `Residence`.`id`)
WHERE `User`.`first_name` IS NOT NULL ORDER BY `User`.`rating` DESC LIMIT 5

You don't have the column "rating" in your "User" table.
The "error" is at:
User::get_top() - APP/models/user.php, line 134
according to your site, at least that's where it's called from.

Related

Alias Name issue in SNowflake

I am using a single query:
(SELECT *,'{"Source": "010","Keys": [{"Value": "CHARGE"}]}' AS ID1
FROM DETAILS) metrics
JOIN DIM.TYPE trant
ON metrics.ID1 = trant.BK_TRANSACTIONTYPE
But I am getting this error:
SQL compilation error: syntax error line 3 at position 30 unexpected
'metrics'.
Please advise how it can be solved.
Can you please try with below query. Hope it works :)
SELECT * FROM (SELECT *,'{"Source": "010","Keys": [{"Value": "CHARGE"}]}' AS ID1 FROM DETAILS) metrics JOIN DIM.TYPE trant ON metrics.ID1 = trant.BK_TRANSACTIONTYPE

PHP PDO Select Format AS Too few parameters

I have the following code:
$extracting = $dbNew->query("SELECT *, Format(Date_Sheet, 'Short Date') AS modifiedDate FROM AccessDB WHERE modifiedDate LIKE '%2021%'");
Having the following error:
Fatal error: Uncaught PDOException: SQLSTATE[07002]: COUNT field incorrect: -3010 [Microsoft Access Driver] Too few parameters. Expected 1.
The problem is the "modifiedDate" because if I replace it with the "Date_Sheet" access field after the database table, I can run the query without issues.
Thank you in advance!

Syntax Error in Azure Data Factory SOQL Query WHERE LastModifiedDate >= datetime

I'm working in Azure Data Factory V2, attempting to query from a Salesforce object where the LastModifiedDate in the object is greater than or equal to a recent date. I've been receiving syntax errors on extremely simple SOQL queries, queries that work just fine in Salesforce Workbench. Below, I've listed examples of queries I've run in the ADF Copy Data activity, along with the errors I received when debugging the pipeline.
Query 1
Select Id from "Object" WHERE LastModifiedDate >=
#{formatDateTime(activity('Yesterday').output.firstRow.Yesterday,'yyyy-MM-ddTHH:mm:ssZ')}
Result 1
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorOdbcOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'Select Id from \"Object\" WHERE LastModifiedDate >= 2018-08-13T16<<< ??? >>>:05:06Z'.,Source=Microsoft.DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=System.Data.Odbc.OdbcException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'Select Id from \"Object\" WHERE LastModifiedDate >= 2018-08-13T16<<< ??? >>>:05:06Z'.,Source=Microsoft Salesforce ODBC Driver,'",
"failureType": "UserError",
"target": "Event Fix Pipeline"
}
Query 2
SELECT Id FROM "Object" WHERE LastModifiedDate >= 2018-08-14T00:00:00Z
Result 2
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorOdbcOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'SELECT Id FROM \"Object\" WHERE LastModifiedDate >= 2018-08-14T00<<< ??? >>>:00:00Z'.,Source=Microsoft.DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=System.Data.Odbc.OdbcException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'SELECT Id FROM \"Object\" WHERE LastModifiedDate >= 2018-08-14T00<<< ??? >>>:00:00Z'.,Source=Microsoft Salesforce ODBC Driver,'",
"failureType": "UserError",
"target": "Event Fix Pipeline"
}
What could be causing this syntax error?
Removing the quotation marks around Object seems to solve your problem.
SELECT Id FROM Object WHERE LastModifiedDate >= 2018-08-14T00:00:00Z.
I tested the query with quotation marks in Salesforce Developer Console and got "Unknown error parsing query", so I believe it's an invalid SOQL query with the quotation marks.
Lol, In my case it was a semicolon at the end of the SOQL statement.

How to find table and column in DB2 with tbspaceid tableid specified in error message

I get following error message when trying to insert an object in the database:
com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException:
DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2,
TABLEID=19, COLNO=0, DRIVER=4.15.134
How can I retrieve the table/column name for which the error is thrown?
Apparently at the package level, DB2 only works with the IDs and not the names.
You can find them back using the following query:
SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME
FROM SYSCAT.TABLES AS T,
SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = 2
AND T.TABLEID = 19
AND C.COLNO = 0
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME

PDOException: SQLSTATE[42S22]: Column not found -- unknown column 'base.status' in 'field list' in node edit

Running Drupal 7.39 with PHP v 5.3.17 and database fully updated.
The problem: Cannot edit any nodes. Clicking EDIT triggers the PDOException error.
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.status' in 'field list': SELECT base.rid AS rid, base.hash AS hash, base.type AS type, base.uid AS uid, base.source AS source, base.source_options AS source_options, base.redirect AS redirect, base.redirect_options AS redirect_options, base.language AS language, base.status_code AS status_code, base.count AS count, base.access AS access, base.status AS status FROM {redirect} base WHERE (base.redirect = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => node/201 ) in DrupalDefaultEntityController->load() (line 198 of /srv/www/htdocs/includes/entity.inc).
Assuming that you have drush installed, run the following:
drush sqlq 'update system set schema_version=7100 where name="redirect"'
drush updb -y
Source: https://www.drupal.org/node/2578019

Resources