Jump to content

error in selector: unknown column in where clause


valan
 Share

Recommended Posts

I've spent few hours at this problem but looks like it needs attention from more qualified people -

(1) there is function like this:

function save_vehicle($wire, $titles) {

    $default = $wire->languages->get("default"); // retrieve English
    $russian = $wire->languages->get("russian"); // retrieve Russian

    $wire->user->language = $default; // whatever current language is, switch it default (English)

    $parentpage = $wire->pages->get('/vehicles/');

    $selector = 'template=vehicle-category, title="'.$titles[1].'"';
    $p = $parentpage->child($selector); // do we already have this category?
    
    if(!$p->id) {

        $p = new Page();
        
        $p->template = 'vehicle-category';
        $p->parent =  $parentpage; // get parent page 
        
        $p->of(false);
        
        $p->title->setLanguageValue($default, $titles[1]); // set in English
        $p->title->setLanguageValue($russian, $titles[0]); // set in Russian

        $p->name = $wire->sanitizer->pageName($titles[1]);
        
        $p->save(); // save the page with the two language values
    }

(2) this function is called in a cycle

(3) when it is is called first time in a cycle - everything is OK, if creates new page as I expect

(4) when it is called second time with same arguments, it produces error in row $p = $parentpage->child($selector);

Error: Exception: Unknown column 'field_title.data1439' in 'where clause' (in /share/MD0_DATA/Web/pw/wire/core/Database.php line 118)

(5) the strange thing (at least for me) is that when I run this cycle once again - everything is OK, e.g. selector works, script detects that page with such title exists and doesn't create new page. 

Please help. Thanks in advance!

Link to comment
Share on other sites

Any of these have the same result... Error: Exception: Unknown column 'field_title.data1439' in 'where clause' (in /share/MD0_DATA/Web/pw/wire/core/Database.php line 118)

$p = $parentpage->child($selector);
$p = $parentpage->children($selector)->first();
$p = $wire->pages->find($selector)->first();

By the way, 1439 is a default language page. Looks like language module somehow related to the error...

Link to comment
Share on other sites

Hi, Valan. Try to sanitize your selector value: $sanitizer->selectorValue($value). If you're using Russian language in your titles I guess you can easily exceed the requirement for the selector string of being less then 100 symbols.
Are you sure you have to look for the existing category by its title and not be the page name?

  • Like 1
Link to comment
Share on other sites

Hi slkwrm!

Thank you for advise - I've changed selector to page name and it start to work without errors!

It is clear now, that problem is in title field. Taking into account that title field is multi-language, I guess problem is in Language module. Somehow it doesn't create column 'field_title.data1439' where 1439 is language page until next run of the same php script......... and this surprises me even more then error. Sanitation didn't help, it reproduces the same error. I also use English language in selector.

So far workaround with page name looks OK for me, but we need to fix original problem or at least understand why it happens - it makes me feel less certain with selectors over multi-language fields now.....

Link to comment
Share on other sites

Hmm.. that's weird. Does your newly created page have a title after the script throws the error? Try to save your page twice in your function: at first with only default title and then with a title in Russian (or save this title field separately). Just to test it. No idea why you have this error. Maybe someone more experienced could help with this.

Link to comment
Share on other sites

Error: Exception: Unknown column 'field_title.data1439' in 'where clause' (in /share/MD0_DATA/Web/pw/wire/core/Database.php line 118)

This is an error MySQL would report if there was no "data1439" column present in the field_title table. I'm guessing that 1439 is the ID of your "default" language. There was a bug in PW related to this that I fixed recently (within the last 3 months I think). Double check that you are using PW 2.3. If you are already using it, you might try switching to the dev branch (at least to test) to see if that fixes it. Please let me know what you find. 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I think this had something to do with FieldtypeConcat? Just reviewing the PM threads with Valan, I think that's how we solved it. Grab the latest version of FieldtypeConcat (I'm assuming you are using it?). Let me know if that's not it. 

Link to comment
Share on other sites

Hi!

Issue with concat was in another thread http://processwire.com/talk/topic/3690-page-cant-be-edited-if-admin-has-non-default-language/ and thanks to Ryan, it's been successfully fixed with update in FieldtypeConcat.module. 

E.g. here we have another error.

Currently I use workaround, e.g. construct selector with other/non-multi-lang fields, particularly use name field and don't use title field (type PageTitleLanguage).

Link to comment
Share on other sites

I'm not sure I've got enough info to go on to fix this one. Can you describe more about how you fixed it with your workaround? Or if anyone has a live example of this issue and doesn't mind giving me access to it, I can troubleshoot it that way too. 

Link to comment
Share on other sites

Hi! I don't know how it works, but it works ))

I've just reconsidered script logic and changed few lines, specifically search field in selector from title (PageTitleLanguage) to name (system/not multi-lang):

    $selector = 'template='.$template_name.', name="'.$pagename.'"';
    $p = $parentpage->child($selector); // do we already have this category?

E.g. the problem is probably in title field.

Currently I don't have live example, may be Sevarf2 has it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...