Jump to content

How can ı use AND OR Operators in SQL Helper Functions


SametALMDR

Recommended Posts

hi everyone ,

I am trying to make an query to database with using SQL helper functions ,but ı want to get data from tblclients table using x data column or y .How can I write it in where part using the below code.

$table = "tblclients";

$fields = "id,firstname,lastname";

$where = array("x"=>"anything","y"=>"anything"); // This part that ı want to do x or y is equal to anything

$result = select_query($table,$fields,$where);

while ($data = mysql_fetch_array($result)) {

      echo $data['id'].$data['firstname'];

}

 

Edited by WHMCS ChrisD
Placed SQL Code into a code box
Link to comment
Share on other sites

20 hours ago, SametALMDR said:

also ı get the example from this link

did you read the first line on that page about this feature being deprecated ? in other words, it's outdated - use capsule.

https://developers.whmcs.com/advanced/db-interaction/

use WHMCS\Database\Capsule;
$brian = Capsule::table('tblclients')->select('id','firstname','lastname')->where('fistname','Brian')->get();

that would give you an array $brian of clients whose first name is "Brian"... which you could then loop through if you wanted to modify it, return it to the template as is or whatever... there are lots of examples of similar queries posted in threads here or you can read the documentation about querying...

https://laravel.com/docs/5.4/queries

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated