Skip to content

How do I traverse CakePHP relations?

I’m trying to traverse the relations on CakePHP models. This is the database: I can access product attributes (product->attributes) on a product model but I cannot access the product attributes on Ad model (ad->product->attributes). Here is my code: And here is what I do in the views: What is w…

Need to remove squre bracket json_encode(array())

Below is my code and it return me json array but i need to remove square bracket from response $sql = “select user_loginId,user_password from wnl_user where user_loginId=’student01′ and user_password=…

Warning: preg_replace(): Unknown modifier

I have the following error: Warning: preg_replace(): Unknown modifier ‘]’ in xxx.php on line 38 This is the code on line 38: How can I fix this problem? Answer Why the error occurs In PHP, a regular expression needs to be enclosed within a pair of delimiters. A delimiter can be any non-alphanumeri…

if and else statement just not working

Here is my if statement. I’m trying to have two differnt options. One is if the user is logged in and the other of course if they’re not. For the life of me I can not get these to work. This is a Word …

Laravel default orderBy

Is there a clean way to enable certain models to be ordered by a property by default? It could work by extending the laravel’s QueryBuilder, but to do so, you’ll have to rewire some of it’s core features – bad practice. reason The main point of doing this is – one of my models ge…