How to Expose a Hierarchy in Groups T-SQL - tsql

I'm trying to figure out a way to handle this hierarchy, but I'm not sure exactly how to. For sake of simplicity, I've made this example data:
CREATE TABLE #EXAMPLE (
ID INT
, PARENT_ID INT
, [PATH] VARCHAR(1000)
, [TYPE] VARCHAR(10)
);
INSERT INTO #EXAMPLE ([ID], PARENT_ID, [PATH], [TYPE]) VALUES
(63812, 0, '/Home', 'Folder')
,(55225, 63812, '/Home/User1', 'Folder')
,(92901, 63812, '/Home/User2', 'Folder')
,(40353, 63812, '/Home/User3', 'Folder')
,(96959, 55225, '/Home/User1/Item1', 'File')
,(97231, 55225, '/Home/User1/Item2', 'File')
,(53339, 92901, '/Home/User2/Item1', 'File')
,(58034, 92901, '/Home/User2/Music', 'Folder')
,(65023, 58034, '/Home/User2/Music/Item1', 'File')
,(72657, 58034, '/Home/User2/Music/Item2', 'File')
,(19406, 58034, '/Home/User2/Music/Item3', 'File')
,(56515, 58034, '/Home/User2/Music/Item4', 'File')
,(68394, 58034, '/Home/User2/Music/Item5', 'File')
,(42813, 92901, '/Home/User2/Movies', 'Folder')
,(32781, 42813, '/Home/User2/Movies/Item1', 'File')
,(96579, 40353, '/Home/User3/Scripts', 'Folder')
,(36300, 96579, '/Home/User3/Scripts/Item1', 'File')
,(59930, 96579, '/Home/User3/Scripts/SQL', 'Folder')
,(83700, 59930, '/Home/User3/Scripts/SQL/Item1', 'File')
,(66753, 59930, '/Home/User3/Scripts/SQL/Item2', 'File')
,(34377, 96579, '/Home/User3/Scripts/Other', 'Folder')
,(20666, 34377, '/Home/User3/Scripts/Other/Item1', 'File')
,(23786, 34377, '/Home/User3/Scripts/Other/Item2', 'File')
,(87107, 34377, '/Home/User3/Scripts/Other/Item3', 'File')
,(29557, 34377, '/Home/User3/Scripts/Other/Item4', 'File')
SELECT E.*
FROM #EXAMPLE AS E
DROP TABLE #EXAMPLE
It's a file path hierarchy, and what I want to do is ultimately make a report that will show, for instance, that there are 16 files under "/Home", and then you could drill-down to the next hierarchy level and see that "/Home/User1" has 2 files, "/Home/User2" has 7 files, and so forth.
I may be overthinking this... but to do so, I believe I have to show elements that are shared in common among the different file paths. At first, I tried something like this (after the table creation statement):
;WITH E_CTE AS (
SELECT E.ID, E.PARENT_ID, E.[PATH], E.[TYPE], [LVL] = 0--, [COMMON_ROOT] = SUBSTRING(E.[PATH], 0, 0)
FROM #EXAMPLE AS E
WHERE E.ID = 63812
UNION ALL
SELECT EXM.ID, EXM.PARENT_ID, EXM.[PATH], EXM.[TYPE], CTE.LVL + 1--, SUBSTRING(EXM.[PATH], 0, CTE.LVL)
FROM E_CTE AS CTE
INNER JOIN #EXAMPLE AS EXM
ON CTE.ID = EXM.PARENT_ID
)
SELECT E.PARENT_ID, [PARENT_PATH] = ISNULL(EXM.[PATH], ''), E.ID, E.[PATH], E.[TYPE], E.LVL
FROM E_CTE AS E
LEFT JOIN #EXAMPLE AS EXM
ON E.PARENT_ID = EXM.ID
ORDER BY E.LVL, E.[PATH]
DROP TABLE #EXAMPLE
This gives me a dataset where I can see the immediate parent of a given record, but I can't see each parent element broken down. A hierarchy of PARENT_PATH and PATH makes it look like there are 9 parent groups, when I want it to show that there is one group at the top, "/Home", three groups at the second level, "/Home/User1", "/Home/User2", and "/Home/User3", and so forth. What I've arrived at is that I need a data set something like this:
CREATE TABLE #EXAMPLE (
ID INT
, PARENT_ID INT
, LEVEL_0 VARCHAR(1000)
, LEVEL_1 VARCHAR(1000)
, LEVEL_2 VARCHAR(1000)
, LEVEL_3 VARCHAR(1000)
, LEVEL_4 VARCHAR(1000)
, [PATH] VARCHAR(1000)
, [TYPE] VARCHAR(10)
);
INSERT INTO #EXAMPLE ([ID], PARENT_ID, LEVEL_0, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, [PATH], [TYPE]) VALUES
(63812, 0, '/Home', NULL, NULL, NULL, NULL, '/Home', 'Folder')
,(55225, 63812, '/Home', '/Home/User1', NULL, NULL, NULL, '/Home/User1', 'Folder')
,(92901, 63812, '/Home', '/Home/User2', NULL, NULL, NULL, '/Home/User2', 'Folder')
,(40353, 63812, '/Home', '/Home/User3', NULL, NULL, NULL, '/Home/User3', 'Folder')
,(96959, 55225, '/Home', '/Home/User1', '/Home/User1/Item1', NULL, NULL, '/Home/User1/Item1', 'File')
,(97231, 55225, '/Home', '/Home/User1', '/Home/User1/Item2', NULL, NULL, '/Home/User1/Item2', 'File')
,(53339, 92901, '/Home', '/Home/User2', '/Home/User2/Item1', NULL, NULL, '/Home/User2/Item1', 'File')
,(58034, 92901, '/Home', '/Home/User2', '/Home/User2/Music', NULL, NULL, '/Home/User2/Music', 'Folder')
,(65023, 58034, '/Home', '/Home/User2', '/Home/User2/Music', '/Home/User2/Music/Item1', NULL, '/Home/User2/Music/Item1', 'File')
,(72657, 58034, '/Home', '/Home/User2', '/Home/User2/Music', '/Home/User2/Music/Item2', NULL, '/Home/User2/Music/Item2', 'File')
,(19406, 58034, '/Home', '/Home/User2', '/Home/User2/Music', '/Home/User2/Music/Item3', NULL, '/Home/User2/Music/Item3', 'File')
,(56515, 58034, '/Home', '/Home/User2', '/Home/User2/Music', '/Home/User2/Music/Item4', NULL, '/Home/User2/Music/Item4', 'File')
,(68394, 58034, '/Home', '/Home/User2', '/Home/User2/Music', '/Home/User2/Music/Item5', NULL, '/Home/User2/Music/Item5', 'File')
,(42813, 92901, '/Home', '/Home/User2', '/Home/User2/Movies', NULL, NULL, '/Home/User2/Movies', 'Folder')
,(32781, 42813, '/Home', '/Home/User2', '/Home/User2/Movies', '/Home/User2/Movies/Item1', NULL, '/Home/User2/Movies/Item1', 'File')
,(96579, 40353, '/Home', '/Home/User3', '/Home/User3/Scripts', NULL, NULL, '/Home/User3/Scripts', 'Folder')
,(36300, 96579, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/Item1', NULL, '/Home/User3/Scripts/Item1', 'File')
,(59930, 96579, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/SQL', NULL, '/Home/User3/Scripts/SQL', 'Folder')
,(83700, 59930, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/SQL', '/Home/User3/Scripts/SQL/Item1', '/Home/User3/Scripts/SQL/Item1', 'File')
,(66753, 59930, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/SQL', '/Home/User3/Scripts/SQL/Item2', '/Home/User3/Scripts/SQL/Item2', 'File')
,(34377, 96579, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/Other', NULL, '/Home/User3/Scripts/Other', 'Folder')
,(20666, 34377, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/Other', '/Home/User3/Scripts/Other/Item1', '/Home/User3/Scripts/Other/Item1', 'File')
,(23786, 34377, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/Other', '/Home/User3/Scripts/Other/Item2', '/Home/User3/Scripts/Other/Item2', 'File')
,(87107, 34377, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/Other', '/Home/User3/Scripts/Other/Item3', '/Home/User3/Scripts/Other/Item3', 'File')
,(29557, 34377, '/Home', '/Home/User3', '/Home/User3/Scripts', '/Home/User3/Scripts/Other', '/Home/User3/Scripts/Other/Item4', '/Home/User3/Scripts/Other/Item4', 'File')
SELECT * FROM #EXAMPLE
DROP TABLE #EXAMPLE
This dataset shows me each row-level item (folder or file), the path, but then the entire "shared path" at each level of the hierarchy. My question is, how do I get from my first dataset to this dataset, using T-SQL? (That is, how do I get to that dynamically?) It would involve a dynamic number of columns depending on how many levels there are (in the production data there's more like seven or eight levels).
A secondary question is this: is there an alternative way to arrange/tabulate/organize this data such that in a reporting tool like SSRS or Tableau, I could drill down from the top level down to the bottom level in the manner I've described?
Thanks to anyone who takes the time to look at this question.

Through some investigation I figured out what I needed, which wasn't what I asked for (didn't have the vocabulary to know what exactly to ask for starting off). After looking at the link from Wise Owl (https://www.youtube.com/watch?v=CHbqIsw5X30&list=PLNIs-AWhQzcmEFHyxCRwA_gb29WOz5SJU&index=28) I also referenced T-SQL Querying by Itzik Ben-Gan (2015) pp. 778-786 and came up with this nested set solution:
DECLARE #root AS INT = 63812;
CREATE TABLE #EXAMPLE (
ID INT
, PARENT_ID INT
, [PATH] VARCHAR(1000)
, [TYPE] VARCHAR(10)
);
INSERT INTO #EXAMPLE ([ID], PARENT_ID, [PATH], [TYPE]) VALUES
(63812, 0, '/Home', 'Folder')
,(55225, 63812, '/Home/User1', 'Folder')
,(92901, 63812, '/Home/User2', 'Folder')
,(40353, 63812, '/Home/User3', 'Folder')
,(96959, 55225, '/Home/User1/Item1', 'File')
,(97231, 55225, '/Home/User1/Item2', 'File')
,(53339, 92901, '/Home/User2/Item1', 'File')
,(58034, 92901, '/Home/User2/Music', 'Folder')
,(65023, 58034, '/Home/User2/Music/Item1', 'File')
,(72657, 58034, '/Home/User2/Music/Item2', 'File')
,(19406, 58034, '/Home/User2/Music/Item3', 'File')
,(56515, 58034, '/Home/User2/Music/Item4', 'File')
,(68394, 58034, '/Home/User2/Music/Item5', 'File')
,(42813, 92901, '/Home/User2/Movies', 'Folder')
,(32781, 42813, '/Home/User2/Movies/Item1', 'File')
,(96579, 40353, '/Home/User3/Scripts', 'Folder')
,(36300, 96579, '/Home/User3/Scripts/Item1', 'File')
,(59930, 96579, '/Home/User3/Scripts/SQL', 'Folder')
,(83700, 59930, '/Home/User3/Scripts/SQL/Item1', 'File')
,(66753, 59930, '/Home/User3/Scripts/SQL/Item2', 'File')
,(34377, 96579, '/Home/User3/Scripts/Other', 'Folder')
,(20666, 34377, '/Home/User3/Scripts/Other/Item1', 'File')
,(23786, 34377, '/Home/User3/Scripts/Other/Item2', 'File')
,(87107, 34377, '/Home/User3/Scripts/Other/Item3', 'File')
,(29557, 34377, '/Home/User3/Scripts/Other/Item4', 'File');
WITH TwoNums AS (
SELECT n FROM (VALUES(1), (2)) AS D(n)
)
, SortPath AS (
SELECT EXM.ID, EXM.[PATH], EXM.[TYPE], TN.n, [LVL] = 0, [SORT_PATH] = CONVERT(VARBINARY(MAX), CONVERT(BINARY(4), TN.n))
FROM #EXAMPLE AS EXM
CROSS JOIN TwoNums AS TN
WHERE EXM.ID = #root
UNION ALL
SELECT E.ID, E.[PATH], E.[TYPE], TNS.n, SP.LVL + 1, SP.SORT_PATH + CONVERT(BINARY(4), (-1 + ROW_NUMBER() OVER(PARTITION BY E.PARENT_ID
ORDER BY E.[PATH])) / 2 * 2 + TNS.n)
FROM SortPath AS SP
INNER JOIN #EXAMPLE AS E
ON SP.n = 1
AND E.PARENT_ID = SP.ID
CROSS JOIN TwoNums AS TNS
)
, Sort AS (
SELECT SP.ID, SP.[PATH], SP.[TYPE], [SortVal] = ROW_NUMBER() OVER(ORDER BY SP.SORT_PATH)
FROM SortPath AS SP
)
, NestedSets AS (
SELECT SRT.ID, SRT.[PATH], SRT.[TYPE], [LFT] = MIN(SRT.SortVal), [RGT] = MAX(SRT.SortVal)
FROM Sort AS SRT
GROUP BY SRT.ID, SRT.[PATH], SRT.[TYPE]
)
SELECT NS.*, EXM.PARENT_ID
INTO #StructureNS
FROM NestedSets AS NS
INNER JOIN #EXAMPLE AS EXM
ON NS.ID = EXM.ID;
SELECT NS.PARENT_ID, NS.ID, NS.[PATH], NS.[TYPE]
, [CNT_FILES] =
(SELECT COUNT(DISTINCT CHLD.ID)
FROM #StructureNS AS PRNT
INNER JOIN #StructureNS AS CHLD
ON CHLD.LFT BETWEEN PRNT.LFT AND PRNT.RGT
WHERE CHLD.RGT - CHLD.LFT = 1
AND PRNT.[TYPE] = 'Folder'
AND CHLD.[TYPE] = 'File'
AND NS.ID = PRNT.ID
)
FROM #StructureNS AS NS
DROP TABLE #EXAMPLE, #StructureNS
What I was going after was how do perform various aggregations (such as a count of files) at each level of a given recursive hierarchy. The T-SQL code does that nicely, though it seems like it would be possible with SSRS and a "Recursive" argument. Either way, the SSRS Recursive advanced setting allows me to display the data in the manner I was looking for, which was to drill down from the root out through all the nodes.

Related

Unable to save address after data migration

One or more input exceptions have occurred.
"postcode" is required. Enter and try again.
"countryId" is required. Enter and try again.
I'm filling these values in my account edit address page, but facing this issue.
https://prnt.sc/u95nez
During migration, there is a problem with the loss postcode and telephone attributes values from customer_form_attribute and eav_form_element tables.
Adding missing values might help:
INSERT INTO customer_form_attribute (form_code, attribute_id)
VALUES ('adminhtml_customer_address', '33'),
('customer_address_edit', '33'),
('customer_register_address', '33'),
('adminhtml_customer_address', '34'),
('customer_address_edit', '34'),
('customer_register_address', '34');
INSERT INTO eav_form_element (element_id, type_id, fieldset_id, attribute_id, sort_order)
VALUES (NULL, '1', NULL, '33', '7'),
(NULL, '2', NULL, '33', '7'),
(NULL, '3', NULL, '33', '6'),
(NULL, '4', NULL, '33', '6'),
(NULL, '1', NULL, '34', '9'),
(NULL, '2', NULL, '34', '9'),
(NULL, '3', NULL, '34', '8'),
(NULL, '4', NULL, '34', '8');

Update a value from one table to another using a Proc

I have two tables with identical structure. One is a Temp table and one is the main table. The table names are PurchaseOrders_TEMP and PurchaseOrders respectively. Each day I refresh the temp table with new data and run a PROC to update the main table with the changes and/or additions. I realized I had an issue if a PO and/or an Item on a PO was completely deleted. My proc is not updating rows that are not in the Temp table. Here is the table definition for PurchaseOrders. I need either a new PROC or an update to this PROC that will change the PBSTAT to 'X' of the PBPO/PBITEM when it does not exist in the TEMP table.
[dbo].[PurchaseOrders](
[ID] [int] IDENTITY(1,1) NOT NULL,
[PBPO] [int] NOT NULL,
[PBSEQ] [int] NOT NULL,
[PBITEM] [varchar](28) NOT NULL,
[PBDEL] [varchar](1) NULL,
[PBVEND] [varchar](9) NULL,
[PBTYPE] [varchar](1) NULL,
[PBLOC] [varchar](4) NULL,
[PBDSC1] [varchar](51) NULL,
[PBDSC2] [varchar](45) NULL,
[PBPDTE] [datetime] NULL,
[PBDUE] [datetime] NULL,
[XDPRVDT] [datetime] NULL,
[XDCURDT] [datetime] NULL,
[PBRDTE] [datetime] NULL,
[PBOQTY] [int] NULL,
[PBTQTY] [int] NULL,
[PBRQTY] [int] NULL,
[PBDQTY] [int] NULL,
[PBLQTY] [int] NULL,
[PBBQTY] [int] NULL,
[PBCOST] [float] NULL,
[EXTCOST] [float] NULL,
[PBCCTD] [datetime] NULL,
[PBCCTT] [int] NULL,
[PBCCTU] [varchar](15) NULL,
[PBLCGD] [datetime] NULL,
[PBLCGT] [int] NULL,
[PBUSER] [varchar](12) NULL,
[PASTAT] [varchar](1) NULL,
[PABUYR] [varchar](3) NULL,
[PAPAD3] [varchar](45) NULL,
[PAPPHN] [varchar](30) NULL,
[PACONF] [varchar](39) NULL,
[Comment] [varchar](max) NULL
Here is the current Proc that I run to update the data.
ALTER PROCEDURE [dbo].[UpdateExistingPurchaseOrders]
AS
BEGIN
SET NOCOUNT ON;
UPDATE
p
SET
p.PBDEL = pt.PBDEL,
p.PBVEND = pt.PBVEND,
p.PBTYPE = pt.PBTYPE,
p.PBLOC = pt.PBLOC,
p.PBDSC1 = pt.PBDSC1,
p.PBDSC2 = pt.PBDSC2,
p.PBPDTE = pt.PBPDTE,
p.PBDUE = pt.PBDUE,
p.PBRDTE = pt.PBRDTE,
p.PBOQTY = pt.PBOQTY,
p.PBTQTY = pt.PBTQTY,
p.PBRQTY = pt.PBRQTY,
p.PBDQTY = pt.PBDQTY,
p.PBLQTY = pt.PBLQTY,
p.PBBQTY = pt.PBBQTY,
p.PBCOST = pt.PBCOST,
p.EXTCOST = pt.EXTCOST,
p.PBCCTD = pt.PBCCTD,
p.PBCCTT = pt.PBCCTT,
p.PBCCTU = pt.PBCCTU,
p.PBLCGD = pt.PBLCGD,
p.PBLCGT = pt.PBLCGT,
p.PBUSER = pt.PBUSER,
p.PASTAT = pt.PASTAT,
p.PABUYR = pt.PABUYR,
p.PAPAD3 = pt.PAPAD3,
p.PAPPHN = pt.PAPPHN,
p.PACONF = pt.PACONF
FROM
dbo.PurchaseOrders_TEMP pt
LEFT OUTER JOIN dbo.PurchaseOrders p
ON p.PBPO = pt.PBPO
AND p.PBSEQ = pt.PBSEQ
WHERE
p.PBPO IS NOT NULL
AND p.PBSEQ IS NOT NULL
END
You can use the MERGE statement to modify data in a target table from data in a source query. The first two examples in the docs show how to insert/update or update/delete depending on whether a source row is found.
In your case you would have to write something like this:
MERGE dbo.PurchaseOrders AS target
USING (SELECT ... FROM PurchaseOrders_TEMP) AS source (...)
ON (ON target.PBPO = source.PBPO
AND target.PBSEQ = source.PBSEQ)
WHEN NOT MATCHED BY SOURCE
THEN DELETE
WHEN NOT MATCHED BY TARGET
THEN INSERT (....)
VALUES (....)
WHEN MATCHED
THEN UPDATE
SET ...
Here is the answer I came up with...
UPDATE
p
SET
p.PASTAT = 'X'
FROM
dbo.PurchaseOrders_TEMP pt
LEFT JOIN dbo.PurchaseOrders p ON
p.PBPO = pt.PBPO
AND p.PBSEQ = pt.PBSEQ
WHERE
pt.PBPO IS NULL
AND pt.PBSEQ IS NULL
AND p.PASTAT <> 'X'
END

TYPO3 Extbase Repository Query: How to find records in M:N relation where several values for N are given?

We have a simple model Company. Each company can have one ore more departments Dept. Each department is of a certain type Type.
Now we need a query where all companies are returned, which have a department of type X and one of type Y at least (i.e. each returned company has two or more departments, at least one X and one Y).
How can that be done with a query?
This query gives no results if getTypes returns more than one type.
if (count($types = $demand->getTypes()) > 0) {
foreach ($types as $type)
$constraints[] = $query->contains('dept.type', $type);
}
$result = $query->matching($query->logicalAnd($query->logicalAnd($constraints)))->execute();
This query returns results for type X or Y
if (count($types = $demand->getTypes()) > 0) {
$constraints[] = $query->in('dept.type', $types);
}
The tables look like this (simplified):
CREATE TABLE IF NOT EXISTS `company` (
`uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(128) NOT NULL,
PRIMARY KEY (`uid`)
);
CREATE TABLE IF NOT EXISTS `dept` (
`uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(128) NOT NULL,
`company` int(10) unsigned NOT NULL,
`type` int(10) unsigned NOT NULL,
PRIMARY KEY (`uid`)
);
CREATE TABLE IF NOT EXISTS `type` (
`uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(128) NOT NULL,
PRIMARY KEY (`uid`)
);
if (count($types = $demand->getTypes()) > 0) {
foreach ($types as $type)
$constraints[] = $query->contains('dept.type', $type);
}
You do not show the further processing.
If you need AND operation use this:
$result = $query->matching($query->logicalAnd($query->logicalAnd($constraints)))->execute();
If you need OR operation use this:
$result = $query->matching($query->logicalAnd($query->logicalOr($constraints)))->execute();
HTH
I found out that $query->contains() only works properly with plain _mm tables.
So this is what I did: I just added a view to the DB which has the required fields for a _mm table:
CREATE VIEW `company_type_mm` AS
SELECT
`company` AS `uid_local`,
`type` AS `uid_foreign`,
0 AS `sorting`,
0 AS `sorting_foreign`
FROM `dept`;
Then I added a new field dept to the TCA of the company table:
'type' => array(
...
'config' => array(
'foreign_table' => 'type',
'MM' => 'company_type_mm',
...
)
)
And now I get the right results for companies which have departments of type A and type B like this:
if (count($types = $demand->getTypes()) > 0) {
foreach ($types as $type)
$constraints[] = $query->contains('type', $type);
}

Perl MySQL Cruddy! Assistance

I am fairly new to database programming and am trying to get a basic CRUD app going. Using Cruddy! I have a very limited application that reads the data dictionary and creates forms based on each table.
As several tables have extensive foreign key entries, I want my app to perform the join operations that would be necessary for each foreign key column to be displayed as the entries to which the key refers. Cruddy! claims to have this ability - it uses CGI::AutoForm for the form creation. To get a form up and running, you have to provide entries on a column-by-column basis to a reference table ui_table_column.
Rather than writing SQL statements for all of my tables and their affiliated columns, I'm trying to get the process right for a single column.
From my DDL for this table:
CONSTRAINT `fk_Holder_Sample1`
FOREIGN KEY (`sample_id`)
REFERENCES `sample` (`sample_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
And my attempts at setting up the AutoForm SQL entries:
INSERT INTO ui_table_column (
table_name, field_name, appear_order, heading, searchable, updatable, insertable, input_control_type, multi_insert_delimiter,
search_control_type, search_mult_select, use_data_dict, datatype, default_value, required, input_size, input_maxlength, brief_heading,
alt_mask_field, mask_table_name, mask_field_name, id_field_name, no_cache, radio_checkbox_cols, field_group, element_attrs, help_summary)
VALUES (
'SAMPLE', 'SAMPLE_ID', 10, 'ID', 'Y', 'N', 'N', 'TEXT', NULL,
'SELECT', 4, 'Y', NULL, NULL, NULL, NULL, NULL, NULL,
NULL, 'sample', 'name', 'sample_id', 'Y', NULL, NULL, NULL, NULL);
INSERT INTO ui_table_column (
table_name, field_name, appear_order, heading, searchable, updatable, insertable, input_control_type, multi_insert_delimiter,
search_control_type, search_mult_select, use_data_dict, datatype, default_value, required, input_size, input_maxlength, brief_heading,
alt_mask_field, mask_table_name, mask_field_name, id_field_name, no_cache, radio_checkbox_cols, field_group, element_attrs, help_summary)
VALUES (
'SAMPLE', 'SAMPLE_NAME', 20, 'Name', 'Y', 'Y', 'Y', 'TEXT', NULL,
'MATCH TEXT', NULL, 'Y', NULL, NULL, NULL, NULL, NULL, 'Name',
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO ui_table_column (
table_name, field_name, appear_order, heading, searchable, updatable, insertable, input_control_type, multi_insert_delimiter,
search_control_type, search_mult_select, use_data_dict, datatype, default_value, required, input_size, input_maxlength, brief_heading,
alt_mask_field, mask_table_name, mask_field_name, id_field_name, no_cache, radio_checkbox_cols, field_group, element_attrs, help_summary)
VALUES (
'HOLDER', 'SAMPLE_ID', 30, 'sample', 'Y', 'Y', 'Y', 'SELECT', NULL,
'SELECT', 4, 'Y', NULL, NULL, NULL, NULL, NULL, 'Sample',
NULL, 'sample', 'NAME', 'SAMPLE_ID', 'Y', NULL, NULL, NULL, NULL);
When I refresh my app page (both just refreshing the broswer and calling apachectl) there is no change - that is, I still see Sample ID as a field in the Holder page.
Has anyone had success with this or can advise me on what I'm doing wrong?
EDIT: The silence from SO I take as indicative that this particular framework has not seen widespread use. I would like to open my question up a little, then, and ask what solutions have you used? I am actually experimenting with Catalyst::Plugin::AutoCRUD.
Answered after learner concluded with another framework but for future reference these fields must be in UPPER CASE.
For the example above, the first and third insert statements would have:
(alt_mask_field, mask_table_name, mask_field_name, id_field_name) = (NULL,'SAMPLE','NAME','SAMPLE_ID').
I wound up using the module in my edit. I will flag this as closed tomorrow.

Sphinx - Cannot use field attribute in query

I cannot use #field-name in my sphinx query, but I can use #*
I could use the #field-name attribute when querying the test.documents example, but not for another table I have indexed.
This is my PHP:
require_once('sphinxapi.php');
$this->sphinx = new SphinxClient;
$this->sphinx->setServer("localhost", 9312);
$this->sphinx->setMatchMode(SPH_MATCH_EXTENDED2);
//This works:
$result = $this->sphinx->query("#* bob");
var_dump($result);
//This doesn't work:
$result = $this->sphinx->query("#artist bob");
var_dump($result);
Output of: /usr/local/sphinx/bin/indexer --all --rotate --dump-rows sphinxrows.txt
# === source src1 ts 1318588067
# Fri Oct 14 10:27:47 2011
#
# field 0: name
# field 1: filename
# field 2: artist
# sql_attr_uint = id_attr # attr 0
# sql_attr_timestamp = date_added # attr 1
#
DROP TABLE IF EXISTS rows_src1;
CREATE TABLE rows_src1 (
id VARCHAR(32) NOT NULL,
id_attr VARCHAR(4096) NOT NULL,
date_added VARCHAR(4096) NOT NULL,
name VARCHAR(4096) NOT NULL,
filename VARCHAR(4096) NOT NULL,
artist VARCHAR(4096) NOT NULL,
KEY(id) );
INSERT INTO rows_src1 VALUES ('6', '6', '0', 'track 1 title', 'track-1.wav', 'bob');
INSERT INTO rows_src1 VALUES ('70', '70', '0', 'track 2 title', 'track-2.wav', 'eric');
Sphinx.conf:
source src1
{
type = mysql
sql_query = \
SELECT id, id AS id_attr, UNIX_TIMESTAMP(date_added) AS date_added, name, filename, artist \
FROM files
sql_attr_uint = id_attr
sql_attr_timestamp = date_added
sql_query_info = SELECT * FROM files WHERE id=$id
}
In sql you have "rows_src1" table , in sphinx.conf you have "files" as table
Field names need to be defined in sphinx.conf. Adding an entry for "rt_field" solved this for me.