草庐IT

masked_where

全部标签

php - 多个连接在 Yii2 的 where 条件下表现不同

$materials=Material::find()->where(['in','Material.MaterialId',$value])->joinWith(['objectName'])->all();$product=Product::find()->where(['Product.productId'=>$id,'Product.ModelId'=>$mid])->joinWith(['product'=>function($query){$query->joinWith(['objectName','contents'=>function($query2){$query2

php - 如何在where条件codeigniter中传递多个Id数组?

我想在where条件下传递多个id怎么办?查询从数据库中获取org_id。现在我想在我的where条件下传递它,那么该怎么做呢?我尝试了foreach循环:下面是我的代码:$devices=$this->activation_m->get_activated_devices();$org_id=array();//createorg_idarrayforeach($devicesas$row){$org_id[]=$row['org_id'];//assignidsintoarray//$companys=$this->data['devices']=$this->activation

php - 在 where 中使用 IN

我在使用MySQLi的where子句中使用IN时遇到了一些问题,这是我的查询:SELECT*FROMcore_tagsWHEREtag_idIN(1,2,3,4,5)GROUPBYtag_idORDERBYtag_popularityASC如果我在PHPMyAdmin中运行它,那么我会得到5个结果,如我所料。但是,如果我使用以下代码在PHP中运行它,我只会得到一个tag_id'1'的结果。这是我的PHP。最初我是使用类中的函数来运行它,但我已经对其进行了手工编码以测试它不仅仅是我的函数中出现相同问题的错误。$mysqli=newmysqli(DB_SERVER,DB_NAME,DB_P

PHP 使用 Where 子句读取 XML

假设我有这个XML文件。1HarryPotter-blablablaJ.KRowling2OtherbookAName有没有一种方法可以让我通过PHP读取并获得#2id,或者我是否必须使用IF?像jQuery选择器':eq(2)',或MySql'WHEREid=2' 最佳答案 有,试试php的SimpleXML解析器:http://php.net/manual/en/book.simplexml.php 关于PHP使用Where子句读取XML,我们在StackOverflow上找到一个类

php - 如何将 WHERE 子句与事件记录分组?

下面的事件记录代码没有像我需要的那样对WHERE子句进行分组......$this->db->where('customers_id',$this->user->getCurrentUserProperty('id'))$this->db->like('delivery_name',$this->input->post('search'));$this->db->or_like('customers_company',$this->input->post('search'));$this->db->or_like('customers_company2',$this->input->p

php - Wordpress WP_Query/get_posts where post_title equals 返回所有结果

我创建了一个名为“片段”的自定义帖子类型,其中包含客户可以更改的数据片段,例如“地址”。片段的标题都是唯一的:我创建了一个简单的函数来返回这些片段,但它运行不正常,我不确定为什么。功能:functionget_snippet($snippet_title){$snippet_page=newWP_Query(array('post_type'=>'snippets','post_title'=>$snippet_title));return$snippet_page->posts[0]->post_content;}下面是一个函数调用示例:echoget_snippet('footer

php - 从特定的 where 子句中获取最高的 id

我的客人数据库中有4条记录。我正在尝试查询具有note_display=1且具有最高ID的guest。我试过了$last_note=DB::table('guests')->where('note_display','=',1)->where('id',DB::raw("(selectmax(`id`)fromguests)"))->first();我得到了Tryingtogetpropertyofnon-object我现在有点卡住了,任何提示都会有很大的帮助吗? 最佳答案 在此查询中无需使用raw。您可以运行一个简单的查询,例如G

php - Laravel 中的高级 Where 子句

我在LaravelEloquent中的查询有问题,我在运行查询时没有得到结果,而且生成的查询似乎不是我所期望的。这是Controller中的代码:$lastUpdate=Input::get('last_update');$userId=Auth::user()->id;$eventIds=EventVendor::where('user_id',$userId)->where('is_active',1)->get()->lists('event_id');$events=EventDetails::whereIn('id',$eventIds)->where(function($q

php - CodeIgniter get_where()与NOT IN

我正在尝试执行一个select语句,该语句将显示与当前文章相关的文章,但将当前文章从选择中排除。选择的前提是它将从当前帖子的类别中选择6个帖子,不包括传递permalink变量的任何帖子。代码:$query=$this->db->get_where('chanl_posts',array('category'=>$category),NOTINarray('permalink'=>$permalink),6);这是我试图不起作用的,并且DOCS声明有一个GETXONEXNOTION()方法,但是这会允许我将类别子句应用到它吗? 最佳答案

php - zend 框架 : how to prepare and execute WHERE IN clause?

我想准备一个在循环内使用的语句。当我尝试执行该语句时,我在日志中看到一条错误消息,提示“参数编号无效:未绑定(bind)任何参数”。我的代码有什么问题?$itemSelectSql="SELECT*FROM`tblItems`WHERE`itemID`IN(?)";$itemSelectStmt=newZend_Db_Statement_Mysqli($this->db_ro,$itemSelectSql);while(){...$itemIds=array();//populate$itemIdsarray...$itemSelectStmt->execute(array($item