草庐IT

Peek-and-select

全部标签

Php Regex查找字符串是否为mysql select语句

我试图在执行查询之前验证查询,如果查询不是mysqlselect语句,那么我必须向用户显示消息。我从这个链接找到了下面的正则表达式:ValidatesimpleselectqueryusingRegularexpression$reg="/^Select\s+(?:\w+\s*(?:(?=from\b)|,\s*))+from\s+\w+\s+where\s+\w+\s*=\s*'[^']*'$/i";接下来我写了下面的代码,但它总是打印不选择查询($match每次都是空的)$string="select*fromuserswhereid=1";preg_match_all($reg,

php - Laravel:让 Eloquent 创建嵌套 SELECT 的正确方法

我试图Eloquent地生成的查询是SELECT*,(SELECTCOUNT(comment_id)FROMcommentAScWHEREc.approved=trueANDc.blog_fk=b.blog_id)AScomment_countFROMblogASb这是结果blog_id|title|author|blog|image|tags|created|updated|comment_count--------|-------------------|--------------|----------------|------------------|---------|---

php preg_split 没有松散的文本,。 : and so forth

我尝试使用preg_split拆分文本,但我没有得到它的正则表达式。例子:Isearch1,regexto:no.Or...yes!应该得到:Array([0]=>I[1]=>search[2]=>1[3]=>,[4]=>regex[5]=>to[6]=>:[7]=>no[8]=>.[9]=>Or[10]=>...[11]=>yes[12]=>!)我尝试了以下代码:preg_split("/([\s]+)/","Isearch1,regexto:no.Or...yes!")结束于:Array([0]=>I[1]=>search[2]=>1,[3]=>regex[4]=>to:[5]=>

php - 如何在 CI 中使用 OR 和 AND 运算符进行查询?

我尝试通过ActiveRecords在Codeigniter中进行查询:if(isset($data['where']['and'])){$this->db->where($data['where']['and']);}if(isset($data['where']['or'])){$this->db->or_where_in('idSpec',$data['where']['or']);}我想得到:WHEREname=1AND(idSpec=2ORidSpec=3ORidSpec=4);但现在我得到:WHEREname=1ORidSpec=2ORidSpec=3ORidSpec=4;

php - 如何在 YII2 ActiveRecord 查询中说 (a AND b) OR (c AND d)?

我在使用YII2的ORM时遇到了困难,它没有记录一些非常简单的典型SQL案例,比如伪代码SELECT*FROMtableWHERE(a=1ANDb=2)OR(a=3ANDb=4)我尝试过的://shouldrepresentthecommentedlogic,butdoesnotDemo::find()->where(...)//(conditionone->andWhere(...)//ANDconditiontwo)->orWhere(...)//OR(!)(conditionthree->andWhere(...)//ANDconditionfour)问题:在YII2中,wher

php - Laravel 5.1 auth attempt with extra parameters using default auth controller and middleware

如何使用默认身份验证Controller和中间件使用额外参数覆盖Laravel5.1身份验证尝试?假设我有一个状态为=active或inactive的额外字段。我该如何编写该尝试方法? 最佳答案 如documentation中所述您可以传递一个变量数组,它们的键是您要在数据库中验证值的列。$request->get('email'),'password'=>$request->get('password'),'active'=>$request->get('active')]);if($attempt){returnredirect

php - 如何在 Doctrine2 SELECT 查询中处理 DateTime 类型的默认值?

我有以下Doctrine2实体:如你所见,我正在使用GedmoTimestampable与Trait由bundle提供。一切正常。当我获取数据并且updated_at列为NULL0000-00-0000时,问题发生了:00:00。对于这种情况,DateTime对象被转换为一个无效日期,如下所示:‌array('RowId'=>26944,'synchflag'=>1,'updatedAt'=>DateTime::__set_state(array('date'=>'-0001-11-3000:00:00.000000','timezone_type'=>3,'timezone'=>'U

php - 如何在 1and1 主机上获取 php 日志

我正在使用1and1Basic计划托管Web应用程序。我尝试按照theirinstructions设置php错误日志记录,因此设置了php.ini如下:error_reporting=E_ALL|E_STRICTlog_errors=Ondisplay_errors=Offerror_log=/homepages/31/d704704531/htdocs/logs/php-errors.log但是它不工作,文件没有被创建,我在任何地方都没有看到错误消息。 最佳答案 问题是目标文件位于logs文件夹中,该文件夹是只读的。这很愚蠢,但需

php - LARAVEL - 未找到基表或 View : 1146 Table doesn't exist (SQL: select * from )

这个问题在这里已经有了答案:DBquerytakingwrongtablenameonlaravel[duplicate](1个回答)Laravel-Database,TableandColumnNamingConventions?(4个答案)关闭去年。我有一个Mysql数据库minho.win和一个名为utilizadores的表。我创建了一个模型类phpartisanmake:modelUtilizador当我执行phpartisantinker然后执行App\Utilizador::all()时,我收到此错误:Illuminate\Database\QueryExceptionw

php - 硅胶 : allow user to change langage by clicking on html element and keeping clean URL

我正在为网站使用Silex和Twig,我希望允许用户更改网站的语言。我的问题现在,如果我更改URL中的语言环境,它就会起作用:/my-account:我的页面内容是英文的(默认_locale)/fr/my-account:我的页面内容是法语/en/my-account:我的页面内容是英文的如何通过单击html元素来执行相同的操作?我正在寻找一些想法来解决我的问题,如果可能的话,我正在寻找一些“以正确的方式”做到这一点的良好实践。我的代码这是我用来管理多语言的Silex组件://TRANSLATION$app->register(newSilex\Provider\LocaleServi