Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by Edward

  1. You can do both ASC and DESC according to the mysql manual.




    Ah well may be not :wacko:


    An index_col_name specification can end with ASC or DESC. These keywords are permitted for future extensions for specifying ascending or descending index value storage. Currently, they are parsed but ignored; index values are always stored in ascending order.

  2. I'm sorry i am confused with what is going on here, it only works in my model if the relationship is BELONGS_TO. Its hard to look at your tables because even with the relationships you have given i don't understand fully what the data is you need to manipulate. The structure of the tables and the data they contain is also important to getting things correct. Well good luck this!

  3. Well if you think about this more carefully you can't display the 5 or 10 in your current CGridView results as this is HAS_MANY data and not BELONGS_TO in which you could bring up the relational data for.


    So the point being you can only display the data in a particular column for data that BELONGS_TO if you wish to get data for HAS_MANY you will need to loop through the array of objects with a foreach loop that is after checking that the returned array is not empty (which you can use the array function count() to test this).


    Therefore the "Trying to get property of non-object" is not coming from the dropdownmenu but the code below.

    'value'     => '$data->course->ects_points',

    You are saying that a course could have a 5 and a 10 or am i confused with something here.

  4. I just checked over your model relations i can confirm they are correct. I will try implementing this type of drop down filter into one of my CGridView's and see if i can get it working now.


    Update: I managed to get the dropdownlist working and now i have it working the same as you did with that same error coming up "Trying to get property of non-object". Okay i will figure this out!

  5. If you are getting the 'property of non-object' error you need to take a look at your model relations make sure they are correct. Is the relationship HAS_ONE or HAS_MANY? If this is a non-object it could be an empty array or an array of objects, just have a look into Ralational Active Record (RAR) in more detail.




    If you show your models and relations it is easy to work out what is wrong if you need more help?

  6. Hello Jonathon, i wanted to ask you have you had issues with the CGridView not updating sometimes when you do an Ajax update to say remove an item you have from the Grid? For me it seems to work on and off, the changes in the database were correct indicating code was correct, even my counters updated but the grid sadly did not.

  7. $this->render('index', array( 'graph' => $graph));

    This statement is correct for passing standard, variables and objects.


    Just one thing i want to say though is all that database access code in the controller is a no no anyway you need to be pushing this into some kind of model or a separate file. It looks like some kind of connection was lost with the variable when you pasted it to the views file. I think what you need to do is create a model function and then access this directly from the views file, rather than passing the $graph object from the controller to the views file.


    Any way this was just a suggestion i haven't used those extensions you are using there so i can't give you the correct answer but something to try, hope it will help in reaching your solution.

  8. Found the book and realize now its not that one but the normal PHP Dynamic websites book, okay i think that message is being printed because in the mysqli_oop_connect.php script contains the code

    if ($mysqli->connect_error) {
        echo $mysqli->connect_error;

    You could just comment out that line to test the difference

    if ($mysqli->connect_error) {
        // echo $mysqli->connect_error;

    Its says connect_error will return a null value of there was no error message. So it may not be this, i did check online and did not find any information on this problem, so i don't know myself if its not this, i never saw this come up on my scripts before. I checked phpinfo() also and did not see any thing related.

  9. The NAME is printed out by $row->name and the DATE REGISTERED is printed out by $row->dr.




    1. $r = $mysqli->query($q); returns a mysql object to $r.


    2. $num = $r->num_rows; the num_rows property in the mysql object $r returns the number of rows


    3. while ($row = $r->fetch_object()) We then use the while loop to loop through each row of data  obtaining $row->name and $row->dr (Name and Date Registered).

  10. I have bitten a little more than i can chew today, run into some major database query frustration, and also found a Yii bug relating to SQL IN and the addInCondition() which was not fixed. But the bug can be fixed by placing addInCondition() after params in the CdbCriteria array. I will get this sorted out tomorrow its time to have a read on joins and stuff, i know the solution to this problem is to use to make the standard SQL solution then convert it into Yii.


    The problem also is you can't feed CGridView with CActiveRecords directly the CActiveDataProvider is made from CActiveRecord but sometimes you need to make CActiveRecords from the start using queries. I don't want to use CdbCriteria i just want to do my work this time from CActiveRecord, arrrgggghhhh! :angry: if you get what i mean!


    The good news though is i have multiple active shopping carts working for a single users buying from mulitiple sellers, it took a bit of array work but i got it done in the end.

  11. Thanks for getting back to me on that, mine does unfortunately, i just wanted to know how you got on with it if you did do it. Its quite a tricky situation but i will figure it out shortly. My project will take to end of next year there is just too much stuff to do and its getting more and more complex the more code that is written. Sometimes i forget i already have functions that do stuff that i think i need to code, its spaghetti junction now, hahaha.

  • Create New...