我有一个这样的代码段:
$pstmt = $connection->prepare($sql);
foo($pstmt);
现在我想记录“foo”方法,即需要准备好的语句。
但我只找到\mysqli_stmt
类。
开始编辑
“更完整”的例子
$connection = pwm\MySQLHelper::getConnection();
$pstmt = $connection->prepare($sql);
$pstmt->bind_param("s", $fbToken);
toJSON($pstmt);
$pstmt->close();
$connection->close();
现在是toJSON($psm)
函数(上面是foo($ps)
/**
* @param $data \mysqli_stmt A prepated statement
*/
function toJSON($pstmt)
{
$pstmt->execute();
$result = $pstmt->get_result();
$rarray = [];
while ($row = $result->fetch_assoc()) {
$rarray[] = $row;
}
$result->close();
echo json_encode($rarray);
}
问题是关于PHPDoc。我无法找到与“mysqli_stmt”不同的类,但是使用此代码,PHPStorm无法识别“execute()”,“get_result()”,“fetch_assoc()”和“close()”。 我想教PHPStorm,这是一个准备好的声明。
我希望编辑有所帮助。
结束编辑
我正在使用PHPstorm并且使用\mysqli_stmt
它无法找到`execute()'等等。
TL;博士;
如何将预准备语句记录为参数,因为\mysqli_stmt
对于PHPStorm来说还不够。
答案 0 :(得分:0)
变量名称和函数参数名称不匹配。在PHPDoc中,您拥有Press 1 to log in or press 2 to sign up
2
Mar 05, 2016 4:51:44 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Mar 05, 2016 4:51:44 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.11.Final}
Mar 05, 2016 4:51:44 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Mar 05, 2016 4:51:44 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Mar 05, 2016 4:51:44 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Mar 05, 2016 4:51:44 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Mar 05, 2016 4:51:45 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Exception in thread "main" java.lang.NullPointerException
at Pizza.OrderTester.main(OrderTester.java:65)
函数private int array[];
private int length;
public void sort(int[] inputArr) {
if (inputArr == null || inputArr.length == 0) {
return;
}
this.array = inputArr;
length = inputArr.length;
quickSort(0, length - 1);
}
private void quickSort(int lowerIndex, int higherIndex) {
int i = lowerIndex;
int j = higherIndex;
int pivot = array[lowerIndex+(higherIndex-lowerIndex)/2];
while (i <= j) {
while (array[i] < pivot) {
i++;
}
while (array[j] > pivot) {
j--;
}
if (i <= j) {
swap(i, j);
i++;
j--;
}
}
// call quickSort() method recursively
if (lowerIndex < j)
quickSort(lowerIndex, j);
if (i < higherIndex)
quickSort(i, higherIndex);
}
private void swap(int i, int j) {
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
public static void main(String a[]){
GUIAdvanceSort sorter = new GUIAdvanceSort();
int[] input = {5,4,3,2,1};
sorter.sort(input);
for(int i:input){
System.out.print(i);
System.out.print(" ");
}
}
。将PHPDoc从$data
更改为$pstmt
。之后它应该按预期工作。