1

I am a newbie in programming and I have a PHP code where I need to connect to the database. I have a line like this:

$where = 'module = "Card"';
$arrDateInfo = $objQuery->select($col, $table, $where);

However this part 'module = "Card"' is not right. I want to get only the data where the module is "Card". Having another table for the module_type is not an option. I cannot find anywhere how to declare a string inside a longer string. Please help!

4

2 回答 2

3

There is a good chance that $where is expecting an associative array.

try this:

$where = array(
    'module' => 'Card'
);

Though, unless you tell us what DB library we're using, we wont know what it expects without being able to look up the function in the documentation for said library.

于 2013-05-07T22:01:13.747 回答
-1

Depending on the database you use, you're going to want to use single quotes around the string in the where clause. I suggest swapping the quotes used, like this:

$where = "module = 'Card'";
$arrDateInfo = $objQuery->select($col, $table, $where);
于 2013-05-07T22:00:20.050 回答