草庐IT

sql-parametrized-query

全部标签

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 - 在不重新加载页面的情况下将数据发布到sql数据库

问题是我无法在不重新加载的情况下将数据插入我的数据库我已经在没有note_sql.js的情况下对其进行了测试,我的note_sql.php工作正常,但我的js文件似乎有问题body可以给我指明正确的方向,那就太好了索引.phpnote_sql.js$("#sub").click(function(){vardata=$("#noteform:input").serializeArray();$.post($("#noteform").attr("action"),data,function(info){$("result_note").html(info);});clearInput(

php - 具有待定状态问题的 WP_Query 和 WooCommerce 订单

我无法获得状态为wc-pending/PendingPayment的订单对象。它只是返回所有订单对象:$my_course_query=newWP_Query(array('post_type'=>'shop_order','post_status'=>'wc-pending','posts_per_page'=>-1)); 最佳答案 YourcodeIsjustworkingperfectlyasexpected,infrontend,Ihavetestitanditoutputonlyorderswith**pendingsta

php - 使用 Laravel 5 执行 SQL 函数

我的数据库中存储了SQL函数。但是,我不能调用它们。$nb=DB::select('SELECTnb_seances_archivees()');结果是:array:1[▼0=>{#186▼+"nb_seances_archivees":0}]但期望的结果只是0。谢谢你的帮助! 最佳答案 默认DB::select返回一个对象数组,你可以使用collections得到第一个结果:$nb=collect(DB::select('SELECTnb_seances_archivees()ASnb'))->first()->nb;或者直接访问

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

mysql - 每周统计的sql查询错误

我正在尝试对用户注册进行每周统计。它应该每周工作一次。一周总共有七天。我想在屏幕上打印一周中每天注册的用户数。例如:NumberofuserswhoregisteredonMonday=38NumberofuserswhoregisteredonTuesday=11........andthislistwillonlylisttheweekwewere我创建了如下的sql查询:SELECTWEEKDAY(registerTime)+1,count(*)FROMusersgroupbyWEEKDAY(registerTime)ORDERBYWEEKDAY(registerTime)但是这

php - 在 Woocommerce 的 WP_Query 循环中显示产品价格

我有这个代码来显示某个类别的产品,我还想显示它的价格。有什么我可以添加或更改的想法吗?下面的代码不显示任何内容(也没有错误)。'product','post_status'=>'publish','posts_per_page'=>10,'tax_query'=>array(array('taxonomy'=>'product_cat','field'=>'slug','terms'=>$product_categories,'operator'=>'IN',))));?>CatNamehave_posts()):?>have_posts()):$wc_query->the_post(

php - 用于 MS SQL Server 的 PDO DBLIB 驱动程序 : Cannot find php_pdo_driver. h

我正在按照下面链接中的教程在我的MacOsMojave中编译PDO的DBLIB驱动程序。https://github.com/BellevueCollege/public-docs/blob/master/PHP/configure-mssql-pdodblib-mac.md问题是,当我运行下面的代码时:$cdphp-7.2.9/ext/pdo_dblib$phpize$./configure--with-php-config=/usr/bin/php-config--with-pdo-dblib=/usr/local/$make$sudocpmodules/pdo_dblib.so/

PHP SQL更新查询

目标我正在尝试更新SQL。我怀疑问题出在我的sql查询或我的连接上。虽然,我可能完全错了。抱歉,如果它很乱,但我正在使用console.log尝试调试问题,控制台输出是:B.1B.2D.1D.2D.3B.2.1B.5关于sql查询,除其他外,我尝试了以下两个:$sql="UPDATEUsersSETdescription=".'$描述'。“哪里用户ID=”。'$this->userID';$sql="UPDATEUsersSETdescription='$description'WHEREuserID='$this->userID'";代码edit-profile-handler.ph

php - 参数太多,预期参数 "command" "sql"

我在写命令的时候遇到了问题:phpbin/consoledoctrine:query:sql'SELECT*FROMcomment'输入后我得到了这个:2019-03-24T13:20:10+00:00[error]Errorthrownwhilerunningcommand"doctrine:query:sql"'SELECT""*"FROM"comment'"".Message:"Toomanyarguments,expectedarguments"command""sql"."太多的参数,预期的参数“command”“sql”。所以我做错了什么?谢谢