-2

I want help in forming this query using class object wrapper(MysqliDb ). You can find here (MysqliDb )

This is the query i needed to convert

SELECT * FROM (SELECT * FROM users WHERE eventId=34) as t2 WHERE name like "alex" or email like "alex";

For Example

    $db = getDbInstance();
    $db->where('eventId', 34);
    $status = $db->get('users');
//SELECT * FROM USERS WHERE eventId=34

Dharman
  • 30,962
  • 25
  • 85
  • 135
vishal
  • 462
  • 1
  • 5
  • 12
  • Why have the subquery? Isn't `SELECT * FROM users WHERE eventId=34 and (name like "alex" or email like "alex")` the same? Please tag the library you are using, and add any errors you are receiving. – user3783243 Jul 20 '22 at 18:50
  • Why are you using this ancient library? I don't think it's maintained anymore – Dharman Jul 20 '22 at 19:08
  • @Dharman then library would be good for PHP – vishal Jul 21 '22 at 06:24
  • @user3783243 no, its now fetching required rows and i want form using this library PHP-MySQLi – vishal Jul 21 '22 at 06:28

1 Answers1

1

I found it this works, by using Having

    $db = getDbInstance();
    $db->having('eventId', 34);
    $db->where('name', '%' . $search . '%', 'like');
    $db->orwhere('email', '%' . $search . '%', 'like');
    $status = $db->get('users');

vishal
  • 462
  • 1
  • 5
  • 12