這是我的函數登錄我調用存儲過程的匹配用戶名和密碼登錄,但它不爲我工作,它給我的所有行:如何在cakephp 3中執行存儲過程?
public function login($email,$password)
{
$consumers = TableRegistry::get('Consumers');
$result=$consumers->query("Call login('".$email."','".$password."')");
pr($result->toArray());die;
}
我的存儲過程在phpMyAdmin是如下:
BEGIN
SELECT * FROM consumers WHERE email = email_id AND password = md_password;
END
,當我執行查詢它給我反對,但這對象轉換爲數組後,給我table.output的所有行:
<pre class="pr">Array
(
[0] => Cake\ORM\Entity Object
(
[_properties:protected] => Array
(
[id] => 1
[name] => jeevan
[email] => [email protected]
[password] => asdf
[phone_no] => 8447726137
[ota] => cde
[status] => 0
[created_on] => Cake\I18n\FrozenTime Object
(
[date] => 2016-07-08 17:28:52
[timezone_type] => 3
[timezone] => UTC
)
[token_access] =>
[device_type] => 1
[push_id] => abc
[want_news] => 1
[postal_code] => 263136
[registration_type] => 1
)
[_original:protected] => Array
(
)
[_hidden:protected] => Array
(
)
[_virtual:protected] => Array
(
)
[_className:protected] =>
[_dirty:protected] => Array
(
)
[_new:protected] =>
[_errors:protected] => Array
(
)
[_invalid:protected] => Array
(
)
[_accessible:protected] => Array
(
[*] => 1
)
[_registryAlias:protected] => Consumers
)
[1] => Cake\ORM\Entity Object
(
[_properties:protected] => Array
(
[id] => 2
[name] => jack
[email] => [email protected]
[password] => 123
[phone_no] => 7409757656
[ota] => chb
[status] => 1
[created_on] => Cake\I18n\FrozenTime Object
(
[date] => 2016-07-20 06:10:14
[timezone_type] => 3
[timezone] => UTC
)
[token_access] => ghcvhgv
[device_type] => 0
[push_id] => hgnjh
[want_news] => 1
[postal_code] => 263136
[registration_type] => 1
)
[_original:protected] => Array
(
)
[_hidden:protected] => Array
(
)
[_virtual:protected] => Array
(
)
[_className:protected] =>
[_dirty:protected] => Array
(
)
[_new:protected] =>
[_errors:protected] => Array
(
)
[_invalid:protected] => Array
(
)
[_accessible:protected] => Array
(
[*] => 1
)
[_registryAlias:protected] => Consumers
)
)</pre>
這意味着存儲過程不工作,任何想法真的幫助我,在此先感謝!
雖然這會起作用,但您現在擁有的是一個可能的SQL注入漏洞!使用綁定/準備語句,或通過驅動程序'quote()'方法手動引用輸入! ** http://book.cakephp.org/3.0/en/orm/database-basics.html#interacting-with-statements** | ** HTTP://api.cakephp.org/3.2/class-Cake.Database.Connection.html#_quote** – ndm