草庐IT

initial_query

全部标签

php - MSSQL 和 PHP : "An invalid parameter was passed to sqlsrv_query."

我试图通过PHP运行一个非常简单的MSSQL更新语句,但我收到一条错误消息*“将无效参数传递给sqlsrv_query。”*这是connectionclass我正在使用,最相关的是查询功能:functionquery($query){$result=sqlsrv_query($query)ordie(print_r(sqlsrv_errors(),true));}最后,这是我用来尝试执行语句的代码:$db=newmssqlClass();$conn=$db->connect();$SQL="UPDATEtableSETTitle='Test'whereID=1"$SQL=$db->qu

php - 警告 : mysql_data_seek(): Offset 1 is invalid for MySQL result index 5 (or the query data is unbuffered)

请任何人提供帮助。我正在尝试执行以下php代码:$sql="SELECT*FROMvendorsWHEREvuid=".$uid."ANDstatus="."'c'";$sql=$sql."LIMIT0,10";$result=mysql_query($sql);$numrows=mysql_num_rows($result);for($i=0;$i0){mysql_data_seek($result,$i);}我收到以下错误警告:mysql_data_seek():偏移量1对于MySQL结果索引5无效(或查询数据未缓冲)。$numrows为2,因此mysql_data_seek的范围

php - POST 请求仅在 php 中使用 http_build_query

我需要使用http_build_query创建一个POST请求。以下是我的代码:$uri_args=array('name'=>'Jack','surname'=>'Jackson','username'=>'jackson12','email'=>'Jack@mail.com',);$uri=http_build_query($uri_args);header("Location:http://samplesite.com?$uri");目前它生成一个类似GET的请求,但我需要POST。考虑到我不想使用curl,...仅使用http_build_query。

php - 如何调试mysqli_query?

这个问题在这里已经有了答案:Whattodowithmysqliproblems?Errorslikemysqli_fetch_array():Argument#1mustbeoftypemysqli_resultandsuch(1个回答)关闭8年前。我连接到我的数据库:$con=mysqli_connect("localhost","xxxx","xxxxx","xxxxxx");//Checkconnectionif(mysqli_connect_errno()){echo"FailedtoconnecttoMySQL:".mysqli_connect_error();}没有返回错

php - Laravel Eloquent : Append queries

是否可以在Laravel中“追加”查询?例如在这个示例代码中:functioncrunchNumbersForToday(){return$this->crunchSomeInformationInRange(Payments::where('created_at',Carbon::now()));}functioncrunchNumbersInRange($range){$paymentsToCrunch=Payment::where('state','payed')->append($range)->get();//Workwiththepayments}因此在这种情况下,crea

php - pg_query 结果包含字符串而不是整数、数字

当我使用pg_query、pg_fetch_assoc从postgresql数据库获取数据时,所有数字字段都以字符串形式返回。有没有办法解决这个问题,还是我必须按照我需要的方式对每个字段进行类型转换? 最佳答案 这就是PHP所做的。来自manual:Eachvalueinthearrayisrepresentedasastring. 关于php-pg_query结果包含字符串而不是整数、数字,我们在StackOverflow上找到一个类似的问题: https:

php - Symfony 2/Doctrine : How to lower the num of queries without losing the benefit of ORM?

我正在使用Symfony2.7和Doctrine。我的Controller操作通常如下所示:#my/namespace/Controller/ItemsController.php->listAction()$items=$this->get('repository.items')->findAll();return$this->render('itemsList.html.twig',array('items'=>$items));在我的模板中,我喜欢迭代关联的实体:#my/namespace/Resources/views/itemsList.html.twig{%foritemi

php - 字符编码和使用 Zend\Dom\Query

我在使用ZendFramework2对波兰语字符进行编码时遇到问题。我使用:useZend\Dom\Query;休息码:$dom=newQuery();$document='ęółąśłżźćtest';$dom->setDocumentHtml($document);$dom->setEncoding('utf-8');$ul=$dom->execute('#testli');foreach($ulas$li){echo$li->nodeValue;}结果:ÄóÅÄÅÅżźÄtest如何正确显示这些字符?我尝试使用PHP函数(iconv、utf8_encode)但没有成功。

php - Laravel Eloquent : dynamically adding parameters to advanced query

我在Laravel中有一个带有字母的数组,例如$letters=array("E","T","R");我现在想将这些添加到高级查询中,以便它最终像这样:Table::where('status',1)->where(function($q){$q->where('city','like',"E%")->orWhere('city','like',"T%")->orWhere('city','like',"R%");});但我不确定如何遍历这些字母。像这样的事情失败了:Table::where('status',1)->where(function($q){foreach($letter

php - 调用未定义的方法 Illuminate\Database\Query\Builder::post()

我在使用查询构建器时遇到问题,在路由文件中使用post()时会出现未定义的方法错误。一般我用的是returnofUser::find($id)->post;但是当我将post作为函数调用时,它不起作用并给我:CalltoundefinedmethodIlluminate\Database\Query\Builder::post()用户模型hasOne('App\Post');}}路线Route::get('/',function(){returnview('welcome');});Route::get('/user/{id}/post',function($id){returnUse