我有一个postgres查询,用于从表“ like”中获取数据
代码为
$query = 'select * from like where (discovery=? and user=?);';
$res = pg_query_params($query, array($_POST['discovery_id'], $_POST['user_id']));
但是在执行时却给出错误
<b>Warning</b>: pg_query_params(): Query failed: ERROR: syntax error at or near "where"
LINE 1: select * from like where (discovery=? and user=?);
^ in
如何正确执行此查询? 我还有另一个名为发现和用户的表。这可能是问题吗?
答案 0 :(得分:0)
尝试
import abc
class BasePlot(metaclass=abc.ABCMeta):
@abc.abstractmethod # this ensures that BasePlot cannot be instantiated
def __init__(self, **kwargs):
self.parameters = kwargs
self.figsize = None # in your example, you use figsize only in __call__
self.nrows = None # declare your instance attributes in the cunstructor
self.ncols = None # declare your instance attributes in the cunstructor
self.setparams() # I would probably add this to __call__ instead of having it here
def setparams(self):
if 'font' not in self.parameters.keys():
self.parameters['font'] = 'serif'
if 'cycle' not in self.parameters.keys():
self.parameters['cycle'] = self.cycle('0')
if 'linestyles' not in self.parameters.keys():
self.parameters['linestyles'] = "paper"
if 'scheme' not in self.parameters.keys():
self.parameters['scheme'] = 'nb'
if 'linestyle' not in self.parameters.keys():
self.parameters['linestyle'] = "ls2"
def cycle(self, n: str):
# this is just a stub method, let it do whatever you need it to do
if n == '0':
return "cycle is 1"
elif n == '1':
return "cycle is 2"
def __call__(self, nrows, ncols, figsize=(9, 6)):
self.nrows = nrows
self.ncols = ncols
self.figsize = figsize
# this is just a stub method, let it do whatever you need it to do
print(self.parameters)
return self.nrows, self.ncols, self.figsize
class DefaultPlot(BasePlot):
def __init__(self, **kwargs): # needed here because the contract requires __init__ to be implemented
super().__init__(**kwargs)
class Standard(DefaultPlot):
pass
def main():
print(Standard(**{'scheme': 'vega'})(1, 1))
print("="*20)
print(DefaultPlot(**{'scheme': 'vega'})(1, 1, figsize=(9.5, 4.5)))
if __name__ == '__main__':
main()
# Output:
# {'scheme': 'vega', 'font': 'serif', 'cycle': 'cycle is 1', 'linestyles': 'paper', 'linestyle': 'ls2'}
# (1, 1, (9, 6))
# ====================
# {'scheme': 'vega', 'font': 'serif', 'cycle': 'cycle is 1', 'linestyles': 'paper', 'linestyle': 'ls2'}
# (1, 1, (9.5, 4.5))