Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted July 21, 20213 yr Have error for MySQL select: $select = \IPS\Db::i()->select( '*', 'news_artcms_news', array('categorynum LIKE ?','%main%'), 'news_artcms_news.num DESC', array( 0, 12 ) ); $results = \IPS\Db::i()->query($select); Quote You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? ORDER BY news_artcms_news.num DESC LIMIT 0,12' at line 1 Where is my mistake? I try to change problems code: array('categorynum LIKE ?','%main%') to array('categorynum = ?','main') but error dont fixed.... categorynum is text field Edited July 21, 20213 yr by Bazilisk
July 21, 20213 yr Try using the like() method instead. Also, you do not need to pass your query to query() - simply convert $select to an array using the iterator_to_array() function. $select = \IPS\Db::i()->select( '*', 'news_artcms_news', array( \IPS\Db::i()->like( 'categorynum', 'main', TRUE, TRUE ) ), 'news_artcms_news.num DESC', array( 0, 12 ) ); $results = iterator_to_array($select);
July 21, 20213 yr Author Thanks. all Ok now. Is it possible to add "AND" rules in WHERE to make second select option? Edited July 21, 20213 yr by Bazilisk