I created a laravel and then - database

Illuminate\Database\QueryException with message 'SQLSTATE[42S02]: Base
table or view not found: 1146 Table
'db_testmasjid.jamaah_model_kajian_model' doesn't exist (SQL: select
kajian.*, jamaah_model_kajian_model.jamaah_model_id as
pivot_jamaah_model_id, jamaah_model_kajian_model.kajian_model_id
as pivot_kajian_model_id from kajian inner join
jamaah_model_kajian_model on kajian.id =
jamaah_model_kajian_model.kajian_model_id where
jamaah_model_kajian_model.jamaah_model_id = 4)'

first you have to run php artisan migrate to create tables in your database and then your query will work perfectly

Related

How to get from which table a particular view is created in Snowflake through query

I am new to snowflake. I am building an application where I need to display the Table information(name and attributes) from which a particular View is created.
example:
Snowflake views with its source tables
So far I have tried the query from the following site but it did not give the source table of a particular view.
https://dataedo.com/kb/query/snowflake/list-views-with-their-scripts
So, is there a query where i can get the source Table of a particular View (with attributes involved).
The view dependencies could be extracted using GET_OBJECT_REFERENCES:
SELECT REFERENCED_DATABASE_NAME,
REFERENCED_SCHEMA_NAME,
REFERENCED_OBJECT_NAME,
REFERENCED_OBJECT_TYPE,
*
FROM TABLE(get_object_references(database_name=>'<db_name>',
schema_name=>'<schema_name>',
object_name=>'<view_name>'));
Column list could be queried using INFORMATION_SCHEMA.COLUMNS.
You can use below sample query to pull column level metadata...
select
-- refr_tab.referenced_database_name,refr_tab.referenced_schema_name, refr_tab.referenced_schema_name,referenced_object_name
ref_cols.*
from
table(
get_object_references(
database_name => 'ex1_gor_y',
schema_name => 'public',
object_name => 'y_view_f'
)
) refr_tab,
information_schema.columns ref_cols
where
refr_tab.referenced_object_type = 'TABLE'
and refr_tab.referenced_schema_name = ref_cols.table_schema
and refr_tab.referenced_object_name = ref_cols.table_name
and ref_cols.table_name = 'Y_TAB_A';

Identity Server with Entity Framework can't authenticate

I am trying to setup client_credentials grant type in identity server 4 using the entity framework project.
I am using a sample config file to populate the database: https://github.com/IdentityServer/IdentityServer4.Demo/blob/master/src/IdentityServer4Demo/Config.cs
This data is entered into the database and I attempt to connect to the token endpoint via Insomnia, here is a screenshot of my setup:
It states invalid_client but I am not sure why, I ran a SQL profile and every time I hit this endpoint its running:
exec sp_executesql N'SELECT [x.Properties].[Id], [x.Properties].[ClientId], [x.Properties].[Key], [x.Properties].[Value]
FROM [ClientProperties] AS [x.Properties]
INNER JOIN (
SELECT TOP(1) [x8].[Id]
FROM [Clients] AS [x8]
WHERE [x8].[ClientId] = #__clientId_0
ORDER BY [x8].[Id]
) AS [t7] ON [x.Properties].[ClientId] = [t7].[Id]
ORDER BY [t7].[Id]',N'#__clientId_0 nvarchar(200)',#__clientId_0=N'client'
It's trying to perform a join on the ClientProperties table, but this table is currently empty. I am not sure if this is the problem or not.
Am I doing something wrong?
When you INNER JOIN two tables, of which one is empty (as you state), the result set will always be empty so when the client can't be retrieved by client_id, you get "invalid_client".
Putting some data, linked to your client, into it should resolve the issue.

QueryException (42S02)

Illuminate \ Database \ QueryException (42S02)
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'influencingquotes.posts' doesn't exist (SQL: select count(*) as aggregate from posts where quote_title = gtav hyhui)
I am not sure why this Database\QueryException is occurring :(
The Error says that the posts table is missing, maybe you forget to run:
php artisan migrate
1.If in database you couldn't find posts table
Then you need to try to find migration file for it
which for laravel 5 located in project_root_dir\database\migrations
Then via command line
php artisan migrate
2.If in database exist table, but name is wrong , for example name is post
In post model you need to specify table name
protected $table = 'post';
If it doesn't help, you need to write us
1.what you see in database, which tables or views exists there
2.What files you see in project_root_dir\database\migrations directory.

How to constrain SQL tables to multiple specific types

I have a small database that I'm developing SQL Server 2008.
I don't have much SQL experience overall, so finding it difficult to find information as to what the appropriate pattern for this issue is.
The main table is 'Provider' a Provider can be a 'MatchService', a 'CompareService', or both depending on 'ProviderTypeId'. I'm looking to contrain data in the MatchService and CompareService tables based on the following rules:
1) A Provider with a ProviderTypeId = Lender can be both a MatchService and a CompareService;
2) A Provider with a ProviderTypeId = Pingtree can only be a MatchService.
I know that a solution probably includes a bridge table in the schema but I'm unsure as to what and where. Any advice appreciated.
Maby something like this:
CREATE TRIGGER MatchService_ITrig
ON MatchService
FOR INSERT
AS
IF NOT EXISTS (
SELECT
ProviderID
FROM
Provider p
INNER JOIN
inserted i ON
P.ID = I.ProviderID
WHERE
ProviderTypeID = 'Lender' OR
ProviderTypeID = 'PingTree'
)
BEGIN
ROLLBACK TRANSACTION
END
How about :
ALTER TABLE CompareService
ADD CONSTRAINT chkPTID CHECK (ProviderTypeId = Lender);
GO
Raj

Doctrine2 issue with running GROUP BY against a MSSQL

I'm trying to run a custom query on my DB with Doctrine2 using the following:
$qb = $em->createQueryBuilder();
$qb->select(array('c', 'count(uc) as numMembers'))
->from('AcmeGroupBundle:Group', 'c')
->leftJoin('c.members', 'uc', 'WITH', 'uc.community = c.id')
->groupBy('c')
->orderBy('numMembers', 'DESC')
->setFirstResult( $offset )
->setMaxResults( $limit );
$entities = $qb->getQuery()->getResult();
This query runs flawlessly on my local MySQL DB. But when I try to run it against my production DB (MSSQL), i get the following error:
SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Column 'Group.discr' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
I do have a discriminator column because I have classes inheriting from Group.
Any suggestions on how should I change the query to make it compatible with MSSQL?
Thanks!

Resources